eclipselink

Parameter in like clause JPQL

Hi, I am trying to write a JPQL query with a like clause: ...LIKE '%:code%' I would like to have code=4 and find 455 554 646 ... I cannot pass :code = '%value%' namedQuery.setParameter("%" + this.value + "%"); because in another place I need :value not wrapped by the % chars. Any help? Thank you ...

Removing an entity, but using the same primary key to add a similar entity after the removal

Im trying to remove an entity which has a unique PK like : 80253 I remove this entity by doing the follow lines of code: myEntityType1 = getEntityManager().find(MyEntityType1.class, 80253); getEntityManager().remove(myEntityType1); getEntityManager().flush(); These bits of code actually deletes the rows from my database and all its ...

JPA Inheritance demands ID in subclass

Hello Everyone I have a problem with my jpa domain model. I am just trying to play around with simple inheritance for which I use a simple Person base-class and and a Customer subclass. According to the official documentation (both, JPA and EclipseLink) I only need the ID-attribute/column in the base-class. But when I run my tests, I al...

How to alter connection in EclipseLink

I use EclipseLink in my application. EclipseLink uses some connection pool. I use EclipseLink internal one. Connection pool creates connection when it is needed and then keeps it for future use. I need to make one specific SQL call on each connection when it is created, but only once. What I need to do is to grant user specific role on ...

JPA: How do I synchronize the persistence context with the result of the bulk update or delete?

Hi all, There's a statement in the ejb-3_0-fr-spec-persistence.pdf which reads The persistence context is not synchronized with the result of the bulk update or delete So if I do a query.executeUpdate which deletes rows from a table. Those same rows still exist in another entities one to many collection. When I restart the applicatio...

Execute "MEMBER OF" query against 'ElementCollection' Map fields in JP-QL (JPA 2.0)

Is it possible to run a "MEMBER OF" query against associative arrays? If so, what does the syntax look like? The obvious workaround is a native query but that gets pretty messy what with all the joins and such. I'd like to test for existence of an object within the map's key set, value collection or entry set. Maybe something like th...

How can I make JDBC drivers pluggable in an OSGi environment?

I have an OSGi project that, among others, contains one bundle with JPA annotated domain models and another which uses Eclipselink as persistency provider. The latter instantiates the EntityManager using a configuration parameter to determine the JDBC driver's class name. Now, the bundle with the models needs to be able to see the JDBC ...

What are reasons for eclipselink failing to autodetect entity classes?

I'm running eclipselink in an OSGi container and my entity classes are in their own bundle. I have repeatedly run into the problem that Eclipselink fails to autodetect the entity classes, resulting in "Xyz is not a known entity type" messages. This is painful to debug and my somewhat helpless approach is to more or less randomly tweak c...

programatically make all relationships CascadeType.MERGE

We have strictly defined which relationships are CascadeType.MERGE in our app. This plays into our version checking (optimistic locking). So, our CascadeType definitions sometimes have MERGE and sometimes not. This is all great for our OLTP application. However, we also have a requirement to load in data (fine to do it batch offline)...

Is there a Maven build for eclipselink that makes the OSGi bundles run in Felix and others?

The Eclipselink OSGi bundles seem have trouble working in some OSGi containers, notably Felix, because they fail to import packages (and that are exported by the system) that they actually require. One example is the missing import of javax.xml.namespace in the core bundle of the current 1.1.3 release. The eclipselink team has targeted ...

Trouble with Aspectj load-time-weaving when using EclipseLink JPA in Spring dm Server 1.x

I am attempting to get EclipseLink JPA working inside the Spring dm Server OSGi environment. Relevant frameworks and libraries downloaded from the Spring Enterprise Bundle Repository include: dm Server 1.0.2.SR02 AspectJ Runtime 1.6.3 AspectJ Weaver 1.6.3 Spring Framework 2.5.6.A Eclipse Persistence 1.1.0 Javax Persistence API 1.99.0...

Example of using CURRENT_DATE in JPA query

Can anyone point me to an example on how to use CURRENT_DATE in a JPA query? CURRENT_DATE is specified in JPA but I haven't been able to make it work. I always get the unexpected token [CURRENT_DATE] exception. Since is specified in JPA all providers should comply with it right? I'm using EclipseLink 2.0 BTW. ...

One persistence-unit, multiple databases with Eclipselink?

Having a single persistence-unit defined in a persistence.xml with all entity specifications, does anyone knows how to make eclipselink load different EntityManagerFactory for different databases in the same running application? Thanks in advance. ...

JPA Entity (in multiple persistence-unit) in OSGi (Spring DM) Environnement is confusing me.

Hi, I'm a bit confused about a strange behavior of my JPA's related objects. I have three bundle : The User bundle does contain some user-related objects, but mainly the User object. The Energy bundle does contain some energy-related objects, and particularly a ConsumptionTerminal which contains a List of User. The Index bundle doe...

Supporting Different JPA GenerationTypes for Test/Production

I want to use GenerationType.IDENTITY for primary keys in my production MySQL system. But for local development and testing, I'd like to use HSQLDB. The problem is that HSQLDB doesn't support GenerationType.IDENTITY (at least with Eclipselink). I tried setting GenerationType.AUTO, which defaults to TABLE for HSQLDB, but unfortunately it ...

EclipseLink, EntityManager with two persistence units needed

Hi, I have one jar library A (or project in eclipse), which has it's own persistence unit (META-INF/persistence.xml) and some entity classes, and another project (B) using this one. In project B there is also persistence unit and entity classes. In project B I need to use both entity classes from project A and B. But if I set "A" as pe...

Parent with cascaded VersionLockingPolicy not picking up database changes to private owned child objects.

I have a parent object with a version locking policy defined as follows: VersionLockingPolicy lockingPolicy = new VersionLockingPolicy(); lockingPolicy.setIsCascaded(true); lockingPolicy.setWriteLockFieldName("CacheId"); descriptor.setOptimisticLockingPolicy(lockingPolicy); and with a child mapped as follows: OneToManyMapping childMa...

EclipseLink JPA @PreUpdate call not persisting

I ran into some similar questions on StackOverflow, tried the solutions, but did not find an answer. I am using a fairly common JPA strategy to set last modified times on some entities. Set up the columns and the fields, then tag a method with @PreUpdate and let it set them equal to the current time. The problem is that I can see in t...

Eclipselink JPA, Oracle, Weblogic, Calling Persist does not commit to database

Hi All, I'm just starting to take a look at java persistence (at the moment with eclipse's default provider of eclipselink). Basically just creating an object and attempting to persist it to the db (Oracle). It was my understanding that the default transactionality should commit the new object to the database when the method retur...

Can I use JPA 2.0 with Google App Engine?

Can I use JPA 2.0(e.g EclipseLink) with Google App Engine? ...