Skip to content

Instantly share code, notes, and snippets.

View thjanssen's full-sized avatar
🎓
Creating the best Java persistence courses for the @Persistence-Hub

Thorben Janssen thjanssen

🎓
Creating the best Java persistence courses for the @Persistence-Hub
View GitHub Profile
@NamedQueries(@NamedQuery(name = "Trip.findByVehicle", query = "SELECT trip FROM Trip trip WHERE vehicle=:vehicle"))
@thjanssen
thjanssen / delete.java
Last active April 26, 2017 08:07
Criteria Update/Delete - The easy way to implement bulk operations with JPA2.1 (http://www.thoughts-on-java.org/2013/10/criteria-updatedelete-easy-way-to.html)
@Stateless
@LocalBean
public class OrderManagement {
@PersistenceContext
private EntityManager em;
...
public void deleteOrder(Double amount) {
CriteriaBuilder cb = this.em.getCriteriaBuilder();
package blog.thoughts.on.java.jpa21.converter;
import java.awt.Color;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
@Converter
public class ColorConverter implements AttributeConverter<Color, String> {
@thjanssen
thjanssen / AuthorEndpointTest.java
Created April 19, 2015 02:59
JBoss Forge - Speedup your enterprise development - Part III Integration Tests with Arquillian (http://www.thoughts-on-java.org/2013/10/jboss-forge-speedup-your-enterprise.html)
@RunWith(Arquillian.class)
public class AuthorEndpointTest
{
@Inject
private AuthorEndpoint authorendpoint;
@Deployment
public static JavaArchive createDeployment()
{
@thjanssen
thjanssen / Author.java
Created April 19, 2015 02:50
JBoss Forge - Speedup your enterprise development - Part II RESTful Webservices (http://www.thoughts-on-java.org/2013/09/rapid-application-development-with.html)
@Entity
@XmlRootElement
public class Author implements Serializable
{
...
@XmlTransient
public Set<Book> getBooks()
{
return this.books;
@Entity
public class Author implements Serializable
{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", updatable = false, nullable = false)
private Long id = null;
@Version
@Column(name = "version")