eclipselink

eclipselink merge() without initial SELECT

我是研究僧i 提交于 2019-12-20 03:03:32
问题 I am trying to perform a merge(entity) using eclipselink, and I would like to indicate to eclipse if that will be an update or insert, so it does not have to perform the initial select query. Thanks to the progress made in this question, I have the following: UnitOfWorkImpl uow = (UnitOfWorkImpl) ((EntityManagerImpl) em.getDelegate()).getUnitOfWork(); if (dbObj.isInDB()) { uow.updateObject(dbObj); } else { uow.insertObject(dbObj); } However, i get the following: org.eclipse.persistence

eclipselink batch write is disabled when use history policy or DescriptorEventAdapter

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 01:36:20
问题 I try to use eclipselink history policy to record the change history of one table/entity. I also use DescriptorEventAdapter/aboutToInsert,aboutToUpdate,aboutToDelete hooks to insert audit record. All things works well except that I found the batch-writing option did not work after I apply the features above. <property name="eclipselink.jdbc.batch-writing" value="JDBC" /> The code is like: for (int i = 0; i <= 3; i++) { MyEntity e= new MyEntity (); e.setName("insert-" + i); entityManager.save

How to set a backreference from an @EmbeddedId in JPA

不想你离开。 提交于 2019-12-19 19:52:38
问题 Does someone know if it is possible to establish a backreference from within a JPA @EmbeddedId . So for example there is an Entity of the Form @Entity public class Entity1 { @Id @GeneratedValue private String identifier; private Entity1 relationToEntity1; //Left out the getters and setters for simplicity } And a second entity with a complex embedded Id. One part of this second entity is a reference to its parent entity. Like so: @Entity public class Entity2 { @EmbeddedId private

How to set a backreference from an @EmbeddedId in JPA

喜夏-厌秋 提交于 2019-12-19 19:51:13
问题 Does someone know if it is possible to establish a backreference from within a JPA @EmbeddedId . So for example there is an Entity of the Form @Entity public class Entity1 { @Id @GeneratedValue private String identifier; private Entity1 relationToEntity1; //Left out the getters and setters for simplicity } And a second entity with a complex embedded Id. One part of this second entity is a reference to its parent entity. Like so: @Entity public class Entity2 { @EmbeddedId private

Cascade persist JPA entities with unknown PK/FK attributes violates NotNullConstraint

随声附和 提交于 2019-12-19 11:38:09
问题 I would like to persist a JPA entity with many 1:1 or 1:many relationships with only one call to persist . Problem: the entity's primary key is auto generated and used as a foreign key in a child entity. When the transaction is committed, there is an exception pointing out a violated NotNullConstraint on the child entity's foreign key column. Internal Exception: java.sql.SQLException: ORA-01400: Insertion of NULL in ("SCHEMA"."PROTOCOL_FILE"."PROTOCOL_ID") not possible Parent entity: @Entity

EclipseLink JPQL (Glassfish v3): join fetch syntax problem?

天涯浪子 提交于 2019-12-19 09:38:58
问题 With Hibernate I'm used to do something like the following: select n from NetworkElement n join fetch n.site s where s.active is true However, EclipseLink complains a lot about this: Caused by: Exception [EclipseLink-8024] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.JPQLException Exception Description: Syntax error parsing the query [select n from NetworkElement n join fetch n.site s], line 1, column 49: syntax error at [s]. (The query on the

Eclipselink extend JOIN clause

╄→尐↘猪︶ㄣ 提交于 2019-12-19 08:27:09
问题 The current code: CriteriaQuery criteriaQuery = cb.createQuery(MinutisPreke.class); Root<MinutisPreke> from = criteriaQuery.from(MinutisPreke.class); Join<LankomumasDiena, MinutisPreke> ld = from.join("lankomumasDiena", JoinType.LEFT); cb.and(cb.equal(ld.get("intervalas"), 7)); generates the following query: SELECT COUNT(t0.pr_id) FROM preke AS t0 LEFT OUTER JOIN lankomumas AS t1 ON (t1.pr_id = t0.pr_id) WHERE (t1.intervalas = 7) How to add statement in the LEFT OUTER JOIN ON clause using

Class not found when using JAX-RS with Eclipse and Glassfish

拟墨画扇 提交于 2019-12-19 07:48:29
问题 I am using Eclipse Luna (versions 4.4.2) and Glassfish 4 to build a REST web-app using JAX-RS. The following piece of code, which is just a very simple post to the REST api that was previously working just fine, has started throw a very strange error: @POST public Response addToWatchlist(WatchlistEntry watchlistentry) { return Response.ok(watchlist_service.addToWatchlist(watchlistentry).toString()).build(); } The error is below: Warning: StandardWrapperValve[Jersey Web Application]: Servlet

How to access multiple tenants in eclipselink?

江枫思渺然 提交于 2019-12-19 04:08:35
问题 Tenants in eclipselink (or Hibernate) are a great concept to separate data domains from each other. I am using eclipselink with single-table strategy. Sometimes it is necessary to access data from more than just one tenant (e.g. for admin purposes). Is there a good way to achieve that? (I do not want to run through all tenants to collect the data...) Example: @Entity @Multitenant @TenantDiscriminatorColumn(name = "TENANT", contextProperty = "tenant.id") public class TenantEntity { ... I can

Schema generation with EclipseLink and Hibernate (JPA2.1) - @ForeignKey ignored

一个人想着一个人 提交于 2019-12-19 03:49:54
问题 I am testing JPA2.1 and the new "schema generation" feature. For that, I tested two implementations under the HyperSQL database : EclipseLink 2.5.2-M1 which is the reference implementation. Hibernate 4.3 I don't have any preference for an implementation (not even for performance). I tested EclipseLink because it was the first JPA2.1 implementation available, but now, Hibernate 4.3 is here and JPA2.1 compliant. The only thing I want is to get something independent from the JPA provider -