eclipselink

JPA Eclipselink: How to find which relationship is causing error

I get the following error when attempting to persist an object: java.lang.IllegalStateException: During synchronization a new object was found through a relationship that was not marked cascade PERSIST Is there any simple way to tell which relationship has the problem object? It is possible that the persisted object has many rela...

Why EclipseLink is adding discriminator column for joined inheritance strategy?

I am using JOINED inheritance strategy with EclipseLink JPA implementation. I have noticed that EclipseLink is adding discriminator column, named by default DTYPE, to the database schema. I understand, that discriminator is needed for one table inheritance strategy, but why for JOINED strategy? EclipseLink needs this column because I've...

JPA and PostgreSQL

I'm on a project that uses the EclipseLink implementation of JPA to talk to a PostgreSQL database. I have a task for which PostgreSQL NOTIFY/LISTEN seems like a perfect fit. Unfortunately, I'm a JPA newb, and am struggling to figure out how to make it work. So I guess I really have two questions; answering either one will make me happ...

Verify JPA column mappings at load time

Current project recently had a mess of changes to the DB schema. These were largely style cleanups, such as ensuring that all columns followed a consistent naming pattern and were all_in_snake_case . I believe we got all of the column references in our DB as well as in our Entities, is it possible to have JPA, EclipseLink, or GlassFish ...

Trouble creating unique table of Strings when persisting List<String>

Suppose I have an entity: @Entity public class AnEntity implements Serializable{ @ElementCollection private List<String> strings = new Vector<String>(); // other stuff } I am using EclipseLink(JPA 2.0). The strings in this List may have the same values in many AnEntity objects. That is to say, many AnEntity objects may referen...

Best Practices for Building Where-In Clause in EclipseLink 1.1

I'm on a project using EclipseLink 1.1, and I have a query where the obvious thing for me to do is use a Where-In clause, like so: List<String> things = populateListOfThings(); String queryString = " select s from Stuff s where s.thing in (:things) "; Query query = em.createQuery(queryString); query.setParamete...

How should one handle a javax.persistence.OptimisticLockException ?

I'm new to JPA so forgive me if not being clear. Basically I want to prevent concurrent modifications by using Optimistic Locking. I've added the @Version attribute to my entity class. I need to know if this algorithm on handling OptimisticLockException is sound. I'm going to use the Execute Around Idiom like so: interface UpdateUnitO...

JPA PreUpdate implemented using DescriptorEventAdapter called after find/select

I have implemented a DescriptorEventAdapter for JPA (eclipselink). It performs simple timestamp operations. The preUpdate method is being called, however it is being called too often. It gets called and updates the timestamp, even on find/select operations. The issue I'm running into appears to occur in a different JPA framework also, h...

Easiest way of programatically checking that a class has a valid JPA defintion

I'm working with many classes which are annotated with javax.persistence.Entity and the like. My project is about generating metadata about JPA-annotated classes rather than persistence by itself, so I'm using them as test cases. Rather than firing up Hibernate or some other JPA provider, I'd like to programatically check - part of my u...

How to safely read related Entities from a detached Entity in JPA

I am trying to attach a related persisted entity to a transient entity. This works fine in GlassFish V2 but not in GlassFish V3. This is a very simple scenario. Please look at the testcase at QueryException when reading Property of detached Entity Many thanks. ...

How to increase PermGen memory for eclipselink StaticWeaveAntTask

We are using Eclipselink and need to weave the code in order for lazy fetching to work property. During the weave process I'm getting the following error: weave: BUILD FAILED java.lang.OutOfMemoryError: PermGen space I have the following tasks within my ant build file: <target name="define_weave_task" description="task defin...

Eclipse link jpa problem

With two users simultaneously using my simple app, I'm getting exception: Error Code: 0 Call: SELECT ID, NAME, IMAGE FROM GameObjectTable ORDER BY ID ASC Query: ReadAllQuery(referenceClass=GameObject sql="SELECT ID, NAME, IMAGE FROM GameObjectTable ORDER BY ID ASC") Caused by: org.postgresql.util.PSQLException: There was In/Out error w...

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

Hi guys, 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.JPQLExcept...

How to release a locked row using JPA?

I'm using the EclipseLink implementation of the JPA 2.0 which allows pessimistic locking. I know how to lock an entity but how do I release the lock? At first I thought this was all taken care of within a transaction (in other words, the entity is locked until you commit the transaction), but that does not seem to be the case. I tried...

Is it possible to output generated SQL using EclipseLink without having to increase log verbosity?

Hello! I want to output the SQL generated by EclipseLink to the console, during development. However, I could only do so using the logging level FINE. I have a complex domain model composed of many classes, so much that deployment takes a considerable ammount of time when the log verbosity is on the FINE level, since EclipseLink outputs...

Classpath entry eclipse.fproj.jdt.libprov.osgi/jpt.jpa is marked for publish/export but is not exported on the project classpath

I'm trying to get a new Enterprise Application Project set up in Eclipse using Glassfish as my app server and I'm seeing the following warning: Classpath entry eclipse.fproj.jdt.libprov.osgi/jpt.jpa is marked for publish/export but is not exported on the project classpath. Classpath visibility within Eclipse and at runtime will differ. ...

use of EntityManagerFactory causing duplicate primary key exceptions

Hey guys, my goal is create an EntityManager using properties dependent on which database is in use. I've seen something like this done in all my Google searches(I made the code more basic for the purpose of this question): @PersistenceUnit private EntityManagerFactory emf; private EntityManager em; private Properties props; @PostCon...

The same objects in JPA

Hello, I have entity model like this (using EclipseLink and JPA 2.0): @Entity class A { @Id @GeneratedValue(strategy = GenerationType.AUTO) Long id; //equals, hashCode autogenerated by nb. } And: @Entity class B { @Id @GeneratedValue(strategy = GenerationType.AUTO)...

How to handle Oracle Store Procedure call with Oracle Types as input or output using EclipseLink

Hi, I doing a Proof Of Concept to figure out how efficient to call a store procedure using EclipseLink. I was able to call oracle store procedure using EclispeLink with Scalar/primitive data types (link Integer, varchar etc). I wanted to understand how can I handle Oracle Store procedure from EclipseLink with collection(Oracle Types/Use...

JPA behaviour...

Hi I have some trouble understanding a JPA behaviour. Mabye someone could give me a hint. Situation: Product entity: @Entity public class Product implements Serializable { ... @OneToMany(mappedBy="product", fetch=FetchType.EAGER) private List<ProductResource> productResources = new ArrayList<ProductResource>(); .... public List<Produ...