Questions tagged [jpa-2.1]

This tag is for questions specifically about new features of version 2.1 of the Java Persistence API.

The Java Persistence API version 2.1 improves JPA 2.0 with features like bulk operations, stored procedure support and new JPQL keywords.

Main features included in JPA 2.1 is:

  • Converters - allowing custom code conversions between database and object types.
  • Criteria Update/Delete - allows bulk updates and deletes through the Criteria API.
  • Stored Procedures - allows queries to be defined for database stored procedures.
  • Schema Generation
  • Entity Graphs - allow partial or specified fetching or merging of objects.
  • JPQL/Criteria enhancements - arithmetic sub-queries, generic database functions, join ON clause, TREAT option.
659 questions
4
votes
1 answer

Is it possible to query JPA entities by ElementCollections where the ElementCollection contains all elements in a given set of elements?

How to use JPQL to query JPA entities by ElementCollections where the ElementCollection contains all elements in a given set of elements? For example, if a Node entity defines an ElementCollection of…
dbschofield
  • 235
  • 3
  • 7
4
votes
1 answer

JPA equivalent command to Hibernate.initialize

I have a Lazy collection that I want to initialize at will in my service/controller. At this moment I can do: Hibernate.initialize( myEntity.getListOfThings() ); This command is hibernate dependent and does not make the implementation of JPA…
borjab
  • 11,149
  • 6
  • 71
  • 98
4
votes
1 answer

How do i use force index with QueryDSL?

I'm currently working on project which uses queryDsl, jpa and hibernate with mysql as database. One of the generated queries took 625 seconds to execute. Since i do not have the freedom to change the indexes on the table itself but i can use force…
geneqew
  • 2,401
  • 5
  • 33
  • 48
4
votes
0 answers

how to specify javax.persistence.Index jpa 2 with inheritance

How do you specify an @javax.persistence.Index for a subclass? When you specify the annotation in the superclass, Hibernate indicates that the column isn't found. But since the @Table annotation is specific to the superclass in a single table…
Marc
  • 6,773
  • 10
  • 44
  • 68
4
votes
1 answer

java persistence collection of metamodel types is empty

While deploying my jpa project to wildfly server i am gettings following warning: The collection of metamodel types is empty. Model classes may not have been found during entity search for Java SE and some Java EE container managed persistence…
Jayendra Gothi
  • 682
  • 2
  • 11
  • 26
4
votes
0 answers

How to set index name on primary key by using @Index JPA annotation?

My tools -> Java 8, JPA 2.1 and Hibernate 4. Im using just JPA2.1 annotations. The code in the dock -> @Entity @Table(indexes = { @Index(name = INDEX_PK, columnList = ID) }) public class Invoice { @Id @GeneratedValue(strategy =…
ame-h
  • 1,617
  • 1
  • 12
  • 13
4
votes
2 answers

JPA2.1 and Hibernate Validator 5.1.2 on Weblogic 12.1.3

I am trying to configure my project to run JPA2.1 with Hibernate Validator 5.1.2 on Weblogic 12.1.3, but I'm running into issues when I try to deploy my project. I configured weblogic to use JPA2.1 using the manual method as described on the tthis…
Waterstraal
  • 399
  • 4
  • 16
4
votes
1 answer

HIbernate one-to-one annotation isn't generating foreign key GerericGenerator in dependent table

I am trying to create OneToOne relation between a Person and Auth table. The problem is when the DB table "Auth" is generated, I'm not seeing the foreign key in the AUTH table that should reference Person. The object is to have the Auth table use…
Dean
  • 887
  • 4
  • 16
  • 42
4
votes
0 answers

JPA 2.1 derby/javadb create script with line breaks will not run

Please have a look on my create script. My goal is to controll the creation of the schema by script and let the dropping be handled by the metadata stuff.
KFleischer
  • 942
  • 2
  • 11
  • 33
3
votes
2 answers

Spring JPA DTO projection and handling the nested projection with null values

I am using class based projection with constructor expressions. here is a sample code form my work @Query("select new com.core.data.category.CategoryDto(c.id,c.code,c.externalCode,c.seoMeta, c.createdAt, c.updatedAt,c.parent.code) FROM Category c…
Umesh Awasthi
  • 23,407
  • 37
  • 132
  • 204
3
votes
0 answers

How to prevent JPA/Hibernate attempts to delete from (read-only) DB view mapped Map property?

I have something like this: @ElementCollection(fetch = FetchType.LAZY) @CollectionTable(name = "my_read_only_view", joinColumns = {@JoinColumn(name = "entity_id", referencedColumnName = "id", updatable = false, insertable = false)}) …
Learner
  • 1,215
  • 1
  • 11
  • 26
3
votes
1 answer

How to specify order of fields inside a composed primary key?

This question is about ordering inside a composed index, which is a more specific problem than ordering columns inside a table. I have a simple class with a composed id: @Embeddable class PrimaryKeyClass { private int a; private int…
krionz
  • 417
  • 1
  • 4
  • 15
3
votes
3 answers

Hibernate executes additional query when fetching the parent-side of a one-to-one entity association

I have these to entities, where FSAK_Nachricht has an @OneToOne relationship to FNACHRICHTAKTSTATUS. @Entity @Table(name = "FSAK_NACHRICHT") public class FsakNachricht implements Serializable { private static final long serialVersionUID = 1L; …
bish
  • 3,381
  • 9
  • 48
  • 69
3
votes
2 answers

Why merge() return copy object?

I am new to JPA, read about merge method which is present in EntityManager, that return a copy object when we try to merge a detached object. Why does it returns a copy object? I tried to detach a managed object and found that the hashcode of the…
3
votes
1 answer

Spring Data JPA Projection nested list projection interface

I have a question about usage of nested list projection interface. I have two entity (Parent and child) (they have Unidirectional association) Parent => @Table(name = "parent") @Entity public class ParentEntity { @GeneratedValue(strategy =…
Batuhan
  • 463
  • 2
  • 6
  • 22