jpa-2.0

@MappedSuperclass static weaving with EclipseLink and multiple jars

…衆ロ難τιáo~ 提交于 2019-12-13 07:31:18
问题 My entities objects are scattered in multiple jars. In jar A I have a base class name MyBase which is annotated with @MappedSuperclass. In jar B there is an entity class which derives from MyBase. The problem is that because the weaving is done in the context of the jar file (I'm using the maven plugin) the base class (MyBase) isn't instrumented (although it should). If I move the derived class from jar B to A then the weaving process will handle the base as well. Since I'm working on a large

JPA - OneToMany relationship not loading children

拟墨画扇 提交于 2019-12-13 06:26:04
问题 I am trying to configure this @OneToMany and @ManyToOne relationship but it's simply not working, not sure why. I have done this before on other projects but somehow it's not working with my current configuration, here's the code: public class Parent { @OneToMany(mappedBy = "ex", fetch= FetchType.LAZY, cascade=CascadeType.ALL) private List<Child> myChilds; public List<Child> getMyChilds() { return myChilds; } } public class Child { @Id @ManyToOne(fetch=FetchType.LAZY) private Parent ex; @Id

Orphan removal not working if not “complete” orphan

人盡茶涼 提交于 2019-12-13 04:25:35
问题 I have public class RelationObject { @OneToMany(orphanRemoval = true, mappedBy = "relationObject") private Set<RelationParticipant> participants = new HashSet<RelationParticipant>(); } public class BusinessObject { @OneToMany(orphanRemoval = true, mappedBy = "businessObject") private Set<RelationParticipant> participants = new HashSet<RelationParticipant>(); } and public class RelationParticipant { @ManyToOne @JoinColumn(name = "ro_id", nullable = false) private RelationObject relationObject;

JPA2, LEFT JOIN, Criteria API

亡梦爱人 提交于 2019-12-13 04:15:34
问题 I have the following situation SQL that I need to implement into my criteria builder for dynamic query creation. select t1.ticketnr from tbl_ticket t1 left join tbl_tickets_updates t2 on t1.ticketnr = t2.ticketnr where t1.description ilike '%EXAMPLE%' or t2.description ilike '%EXAMPLE%'; In my code I have the following: tbl_ticket = Tickets.class PK = ticketnr tbl_tickets_updates = TicketsUpdates.class and TicketsUpdatesPK.class PK = ticketnr, updatedby, timeofupdate CriteriaBuilder builder =

QueryException: could not resolve property: DESC

对着背影说爱祢 提交于 2019-12-13 03:46:27
问题 I want to count the several rows using JPA. My Code: String hql = "SELECT count(e.id) as count, e.status, e.error_class, e.error_message, e.id, e.settlement_status_raw FROM " + PaymentTransactions.class.getName() + " e WHERE e.terminal_id = :terminal_id AND (e.createdAt > :created_at) AND (e.status != 'approved') GROUP BY e.error_message ORDER BY count DESC"; TypedQuery<PaymentTransactions> query = entityManager.createQuery(hql, PaymentTransactions.class).setParameter("terminal_id", terminal

Cache Isolation Level Warning on Parent Entity

时光毁灭记忆、已成空白 提交于 2019-12-13 00:16:44
问题 After adding a second persistence unit and changing my application's data sources to XADataSource (MySQL), I'm now getting a confusing warning in the glassfish log about isolation levels on my parent entity: WARN o.e.p.s.f.j.ejb_or_metadata : Parent Entity BaseEntity has an isolation level of: PROTECTED which is more protective then the subclass Contact with isolation: null so the subclass has been set to the isolation level PROTECTED. After some research, I think that this isolation level

What does PersistenceUtil.isLoaded means?

允我心安 提交于 2019-12-13 00:12:25
问题 Could somebody explain what does PersistenceUtil.isLoaded returns in the context of JPA and hibernate. My impression was that it identifies if the value is loaded and can be accessed without database access. But recently I came upon a case that PesistenceUtil.isLoaded returns true, while the object is an instance of HibernateProxy, and any access to it throws a LIE. I would appreciate any comments. 回答1: Method isLoaded in PersistenceUtil checks is entity loaded. Entity being loaded means that

Cannot use an @IdClass attribute for a @ManyToOne relationship

旧城冷巷雨未停 提交于 2019-12-12 18:30:06
问题 I have a Gfh_i18n entity, with a composite key ( @IdClass ): @Entity @IdClass(es.caib.gesma.petcom.data.entity.id.Gfh_i18n_id.class) public class Gfh_i18n implements Serializable { @Id @Column(length=10, nullable = false) private String localeId = null; @Id <-- This is the attribute causing issues private Gfh gfh = null; .... } And the id class public class Gfh_i18n_id implements Serializable { private String localeId = null; private Gfh gfh = null; ... } As this is written, this works. The

JPA: How to count child records without loading a lazy loaded set

大憨熊 提交于 2019-12-12 18:19:56
问题 I'm writing a J2EE/JPA/Spring 3 application, trying to stay pure JPA 2.0. I want to get a count of child objects without having to load them, as it's obviously an expensive operation. For example here's a simplified example Organisation - OrgID - OrgName Employee - EmployeeID - OrgID (key to Organisation table) - EmployeeName On a jsp page I want to show the list of all organisations and a count of the number of employees without loading the employees themselves. If it can be a single

Why does eclipselink consume the whole allocationSize each time it's rebooted?

↘锁芯ラ 提交于 2019-12-12 17:47:50
问题 I've just noticed that for my entity's id, eclipselink assigns an id 1 + the previously greated assigned IN THE SAME SESSION (1), as opposed to in the element table (2). This goes against my application expectations. What's the easiest way to tell it to do 2? @Id @GeneratedValue(strategy = GenerationType.AUTO) private int objId; And here is what I have in the database: ij> connect 'jdbc:derby:db'; ij> set schema memo; 0 Zeilen eingef?gt/aktualisiert/gel?scht ij> select * from meaning; OBJID