jpa-2.0

JPA 2.0 in WebLogic Server 10.3.6

a 夏天 提交于 2019-12-04 12:41:36
I need to use JPA 2.0 (with the EclipseLink implementation). The problem is that I also need to deploy this app in a WebLogic 10.3.6 server, which implements the Java EE 5 specification, and so, it is not required to support JPA 2. I know that there are patches that can be used to add support for JPA 2.0 in this version , but the sysadmin doesn't want to change anything in the server at all I tried adding the javax.persistence-2.1.0.jar file to my war thinking that my app would just use this file instead of the one provided by WebLogic. Does this make any sense? Is there a way to achieve this

Many to many association without join table

旧街凉风 提交于 2019-12-04 12:38:43
I'd like to apply JPA in the following (simplified) database: NODE AUTHORITY ----- ---------- idNode int idAuthorities int nameNode varchar(50) person varchar(255) idAuthorities int rank int PRIMARY KEY (idNode) PRIMARY KEY (idAuthorities, rank) FOREIGN KEY (idAuthorites) So one node can have multiple authorities and one authority can be referenced by multiple nodes. And I wanted my classes to look like: @Entity @Table(name="NODE") public class Node { private Integer id; private String nameNode; private Set<Authority> authorities; // ... getter and setter normaly annoted for "id" and "nameNode

JTA or LOCAL transactions in JPA2+Hibernate 3.6.0?

不打扰是莪最后的温柔 提交于 2019-12-04 12:21:06
问题 We are in the process of re-thinking our tech stack and below are our choices (We can't live without Spring and Hibernate due to the complexity etc of the app). We are also moving from J2EE 1.4 to Java EE 5. Technology stack Java EE 5 JPA 2.0 (I know Java EE 5 only supports JPA 1.0 but we want to use Hibernate as the JPA provider) Hibernate 3.6.0 (We already have lots of hbm files with custom types etc. so we doesn't want to migrate them at this time to JPA. This means we want both jpa/hbm

Triggers vs. JPA @PrePersist for creation and update timestamps pros and cons

北战南征 提交于 2019-12-04 11:56:02
问题 I am building a new web app and I am using Spring, JPA/Hibernate, and Postgres. Some of my tables have creation_ts and lastupdate_ts columns which are timestamp columns that track when an insert occurred and when the last update occurred on a row. I am also using a naming convention for columns in my tables so as a matter of design policy every table is guaranteed to have two columns pkey which is an integer surrogate key, and version for optimistic locking. I have two ways to keep these

Hibernate exception with @MapsId, @EmbeddedId

前提是你 提交于 2019-12-04 11:54:12
问题 I've got a problem with @MapsId annotation and @EmbeddedId . When running a code in Hibernate I get: Caused by: org.hibernate.PropertyAccessException: could not set a field value by reflection setter of com.test.entities.EmployeeId.serverId But, let's start from the beginning... I have a composite primary key for entity Employee which consists of foreign keys to two other entities ( Server and Website ). In order to have a clean design I use entity relationships in Employee entity which

How to layout Java EE projects using common JPA entities?

微笑、不失礼 提交于 2019-12-04 11:46:07
I have two eclipse Java EE 6 projects packaged in a WAR-file using maven 3. Now they should share JPA entities in a 3rd project among them, since they both use the same database. When doing the research for my question, I found some hints mentioning for example a reference in a persistence.xml to a common jar, but I wasn't successful to make it work. So specifically asked: 1) Does the project, containing the common entities, has a persistence.xml file? If so, how does it differ from the one in the other projects? 2) How exactly are the commonly used entities referenced in the two projects? Do

jpa lazy fetch entities over multiple levels with criteria api

末鹿安然 提交于 2019-12-04 11:05:40
问题 I am using JPA2 with it's Criteria API to select my entities from the database. The implementation is OpenJPA on WebSphere Application Server. All my entities are modeled with Fetchtype=Lazy. I select an entity with some criteria from the database and want to load all nested data from sub-tables at once. If I have a datamodel where table A is joined oneToMany to table B, I can use a Fetch-clause in my criteria query: CriteriaBuilder cb = entityManager.getCriteriaBuilder(); CriteriaQuery<A> cq

Creating queries using Criteria API (JPA 2.0)

僤鯓⒐⒋嵵緔 提交于 2019-12-04 10:49:28
问题 I'm trying to create a query with the Criteria API from JPA 2.0, but I can't make it work. The problem is with the "between" conditional method. I read some documentation to know how I have to do it, but since I'm discovering JPA, I don't understand why it does not work. First, I can't see "creationDate" which should appear when I write "Transaction_." I thought it was maybe normal, since I read the metamodel was generated at runtime, so I tried to use 'Foo_.getDeclaredSingularAttribute(

How can i inner join a subquery in JPQL

一个人想着一个人 提交于 2019-12-04 10:05:37
I need a JPQL for the MySQL query: SELECT * FROM table1 t1 INNER JOIN table2 t2 ON t1.id = t2.table1.id INNER JOIN (SELECT * FROM table1 t3 INNER JOIN table2 t4 ON t3.id = t4.table1.id WHERE t3.name = 'xxx') subTable ON t1.number = subTable.number WHERE t1.number = '5' AND id = '3' Your query seems quite pathological, perhaps say what result you are trying to query, and include your object model. In general, JPQL does not support sub-selects in the from clause, so your query is not directly convertable to JPQL. You can always just execute it as a JPA native SQL query, since you seem to be

Criteria Builder Create new Object In Select Statement

五迷三道 提交于 2019-12-04 08:06:49
问题 I was wondering if it's possible to create such query like : em.createQuery( "SELECT NEW EmpMenu(p.name, p.department.name) " + "FROM Project p ").getResultList(); also is it possible to do it via Specification: public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder cb) { return ???; } Thanks in advance! 回答1: Yes, Criteria API does have have construct similar to JPQL constructor expressions. Result class is set via construct method in CriteriaBuilder. Your JPQL