eclipselink

Difference Hibernate 3.5 / JPA 2.0

So far, I always prefered to use Hibernate directly rather than JPA 1.0, because JPA was lacking some of the important features I needed and Hibernate provided: Criteria API, second level cache, unidirectional OneToMany and a few others. Now, with the advent of JPA 2.0 and all the new features that come with it and that were initially m...

EclipseLink: Query to MappedSuperclass fails

My application is a store selling fishes, aquariums etc. I want to get a list of top 10 items among all the items based on sales count. I use the following class: @MappedSuperclass @NamedQueries({ @NamedQuery(name="getTopItems",query="SELECT x FROM FishStoreItem x ORDER BY x.salescnt DESC, x.title DESC") }) public abstract class Fis...

How to cascade persist using JPA/EclipseLink

I am having problems performing a cascade persist operation on a parent entity. When the child entity is persisted, the reference (generated id) to the parent entity is null. How would I get this to persist correctly? Thanks, RG Entities: @Entity public class Contact { @Id @GeneratedValue(strategy=GenerationType.TABLE, gen...

TopLink 11g versus EclipseLink

We're considering migrating to TopLink 11g JPA from Oracle Kodo JDO. But I see that EclipseLink exists and appears to be, perhaps, better thank Toplink. The wiki article on it currently states EclipseLink is based on the TopLink product, which Oracle contributed the source code from to create the EclipseLink project. The origin...

JPA - EclipseLink - How to change default schema

I'm programming a web application using weblogic and oracle. the datasource is configured through JNDI, with a restricted database user who can DML into tables, but can't DDL. As you may guess, that user isn't the owner of those tables, but he's granted access. Let's say he is GUEST_USER The application is using JPA + EclipseLink, and ...

EclipseLink : No Persistence provider for EntityManager named ...

Hi everybody, I'd like to create one Bundle that is able to use Java Persistence. To achieve this, I've created a plugin project within Eclipse. In my project, I've created a persistence.xml file into META-INF. I've aslo added in my MANIFEST.mf (into the depencies) those 3 packages : javax.persistence.jar org.eclipse.persistence.jar o...

Problem on persistence Unit and Oracle NLS

Hello people.. I have this persistence unit: <?xml version="1.0" encoding="UTF-8"?> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"&gt; <p...

Hibernate or EclipseLink for JPA?

I was wondering if anyone has experience with the JPA2.0 implementation of any of those frameworks? Especially together with Spring3.x which comes with EclipseLink support. Do you use any of those frameworks and JPA2.0 for production? Any severe issues? ...

Eclipselink : How do you get the EntityManager in each bundle?

Hi! I wonder about a good way to have an EntityManager in each Bundle. Or how to use correctly JPA in an OSGi program. Actually, I've one main bundle that loads the persistence.xml file and instanciates the EntityManager. After, my main bundle gives the instance of Entity manager to the other bundles via the services. So I use the powe...

JPA Entity Manger Factory injection fails (JPA 2, Eclipselink, J2EE 6)

I am trying to get a small sample web app up and running but I have run into a problem injecting the Entity Manager Factory. My persistence.xml is as follows; <persistence version="2.0" xmlns=" http://java.sun.com/xml/ns/persistene" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java...

JPA - Using insertable/updatable

I am writing a webservice to maintain a database. I am trying to use JPA (EclipseLink) for the entity classes. However, the database uses natural primary keys and therefore there's potential that an update on the ID fields will fail due to foreign key constraints. Our DBA has provided a function to update the ID fields which will crea...

NPE Thrown Marshalling Entity in JAX-RS

I have a JAX-RS webservice that makes use of JPA entity classes. I have a resource class like this: @Path("/entity") public class MyEntityResource { @GET @Produces(MediaType.APPLICATION_XML) @Path("/{entity}") public MyEntity getMyEntity(@PathParam("entity") String entity) { log.debug("Entering getMyEntity w...

How to get the primary key of any JPA entity?

For every @Entity I need to perform the following: public <Entity> boolean insert(final Entity entity){ if (em.find(entity.getClass(), entity.getId()) == null) { et.begin(); em.persist(entity); et.commit(); return true; } return false; } That is persist the entity if it didn't exist, and kno...

How do I delete all JPA entities?

Hello, In my testing code I need to have a blank/empty database at each method. Is there code that would achieve that, to call in the @Before of the test? ...

How to write DDL in the criteria API?

Consider the code in http://stackoverflow.com/questions/3333308/how-do-i-delete-all-jpa-entities The documentation here http://download.oracle.com/docs/cd/E17410_01/javaee/6/tutorial/doc/gjitv.html describes only queries. ...

Under what conditions would SELECT by PRIMARY KEY be slow?

Chasing down some DB performance issues in a fairly typical EclipseLink/JPA application. I am seeing frequent queries that are taking 25-100ms. These are simple queries, just selecting all columns from a table where its primary key is equal to a value. They shouldn't be slow. I'm looking at the query time in the postgres log, using the...

JPA @Enumerated Error

Hi, I have a Entity with a field which I want to be an Enum. @Column(name = "TEMPRATURE_ZONE") @Enumerated(STRING) private TemperatureRegime tempratureZone; The Enum is defined as follows: public enum TemperatureRegime { AMBIENT, CHILL } The data in my table for this field is always "AMBIENT" or "CHILL" yet when I do a fi...

Hibernate Serialization Exception in GWT but Eclipselink not

Dear members, I am using eclipselink JPA implementation (Entity) with GWT 2.0 framework on presentation layer. Everything is working properly. But when i change my JPA implementation to Hibernate, I get Serialization/Deserialization Exception on GWT Layer when I pass entity beans but It is okay on eclipselink JPA. Whats really happens? H...

Configure cache expiry at persistence.xml for shared cache

Hi all, Is there a way to configure the cache expiration for the EclipseLink's shared cache using a property in persistence.xml? I do not want to use the annotation, since all my named queries reside at the orm.xml file (used solely for this purpose). I searched for something like "eclipselink.cache.shared.expiry", but couldn't find an...

JPA @Transient fields being cleared before @PreUpdate method is called.

I have an User Entity class that I'm trying to do password hashing for. I thought that the easiest way to do this would be to create a password field annotated with @Transient and a hashed password field that is set just before the object is persisted with a method annotated with @PrePersist and @PreUpdate. So I have something like this...