jpa

EclipseLink: onetomany relationships with lazy loading loaded with serialization

Hello, I'm facing a problem with eclipselink under websphere 7.0 in a clustered environment. When my entity is serialized every 1-n relationship lazy is loaded, even if the entity is detached. How can I avoid this behavior, without having to use DTO? Thank you very much ...

JPQL get most recent rows

Let's say I have the following tables my_profile_data ------------- integer: my_profile_data_id integer: profile_id integer: profile_data_type_id date: date_changed string: value my_profile ------------- integer: profile_id string: name profile_data_type ------------- integer: profile_data_type_id string: name I want to get the most...

How to set up jndi.properties for DataStore?

I'm struggling to set connect a Java program to MySQL using JPA/Hibernate. I'm currently getting the following error when I try to call createEntityManagerFactory(): [main] ERROR org.hibernate.connection.DatasourceConnectionProvider - Could not find datasource: java:jdbc/myDataDS javax.naming.NoInitialContextException: Need to specify ...

JPA persistence.xml share same jar file

Hi! I'm wondering if I can share the same jar file for several persistence units.. I mean: I have two persistence units described in my persistence.xml file and the entities are not in the same JAR. Entities are in a separated JAR file but, in that one, there are entites for both persistence units. I think I red somewhere that I coould u...

How to handle large dataset with JPA (or at least with Hibernate)?

I need to make my web-app work with really huge datasets. At the moment I get either OutOfMemoryException or output which is being generated 1-2 minutes. Let's put it simple and suppose that we have 2 tables in DB: Worker and WorkLog with about 1000 rows in the first one and 10 000 000 rows in the second one. Latter table has several fi...

Update n number of records using JPA with Optimistic locking

I have a table with a column called "count" and I want to run a cron job that will trigger a statement that performs a SQL like this: update summaryTable set count=4; Note that there might be concurrent threads reading & changing the value for "count" when this cron job is triggered. The table has a version column to support Optimisti...

Ability to switch Persistence Unit dynamically within the application (JPA)

My application data access layer is built using Spring and EclipseLink and I am currently trying to implement the following feature - Ability to switch the current/active persistence unit dynamically for a user. I tried various options and finally ended up doing the following. In the persistence.xml, declare multiple PUs. Create a clas...

How to Map a table with another lookup table using JPA?

Hi, I have two tables: 1) Application(int appid, int statusid, String appname, String appcity with getter and Setter methods) 2) App_Status(int statusid,String statusDescription with setter and getter methods) I want to map Application table with App_Status so that I don't have to query separately App_Status table in order to get the...

How to include external classes in a GAE deployment?

I am using the Google plug-in for Eclipse and have the following problem: The project (A) consists of a GWT based GUI talking to a server running on GAE and using JPA. Additionally there is a project (B) to migrate the legacy data to the new datastore. Since these both project use a common data model, I have extracted a set of interface...

JPQL IN clause: Java-Arrays (or Lists, Sets...)?

I would like to load all objects that have a textual tag set to any of a small but arbitrary number of values from our database. The logical way to go about this in SQL would be to build an "IN" clause. JPQL allows for IN, but it seems to require me to specify every single parameter to IN directly (as in, "in (:in1, :in2, :in3)"). Is th...

How to introduce multi-column constraint with JPA annotations?

I am trying to introduce a multi-key constraint on a JPA-mapped entity: public class InventoryItem { @Id private Long id; @Version private Long version; @ManyToOne @JoinColumn("productId") private Product product; @Column(nullable=false); private long serial; } Basically (product, serial) pair s...

again about JPA/Hibernate bulk(batch) insert

Here is simple example I've created after reading several topics about jpa bulk inserts, I have 2 persistent objects User, and Site. One user could have many site, so we have one to many relations here. Suppose I want to create user and create/link several sites to user account. Here is how code looks like, considering my willing to use ...

Hibernate: same generated value in two properties

I want the first to be generated: @Id @Column(name = "PRODUCT_ID", unique = true, nullable = false, precision = 12, scale = 0) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PROD_GEN") @BusinessKey public Long getAId() { return this.aId; } I want the bId to be initially exactly as the aId. One approach i...

EJB 3.1 Embedded API - Unit test EJB + JPA entities.

Has anyone done this or attempted to do this for a preexisting project? It seems there are two options to go with here, either using the embedded EJB API basically the following class javax.ejb.embeddable.EJBContainer Which expects a configured glassfish v3 install to be available (application scoped resources will make this easier)...

How to handle "null primary key encountered" exception in eclipselink?

Hi. I'm catching ... Null primary key encountered in unit of work clone ... exception in eclipselink(2.0.2 with 2.0 jpa) literally meaning that id in my entity is <=0 (for primitive types). Though debug here states that everything's fine and I have nothing to worry about. My AS is glassfish v3. Can any one point out what may cause suc...

Websphere 7 EntityManagerFactory creation problem

Hello, I'm working on a maven project which uses seam 2.2.0, hibernate 3.5.0-CR-2 as JPA provider, DB2 as database server and Websphere 7 as application server. Now I'm facing de following problem: In my EJBs that are seen also as SEAM components I want to use the EntityManager from EJB container (@PersistenceContext private EntityMan...

JPA Cascade delete.

Hi, I am new to JPA/Hibernate. Currently using EJB3, Hibernate/JPA. I have an inheritacnce structure as follows.. @Entity @DiscriminatorColumn(name = "form_type") @Inheritance(strategy = InheritanceType.JOINED) @GenericGenerator(name = "FORMS_SEQ", strategy = "sequence-identity", parameters = @Parameter(name = "sequence", value = "FO...

Seam 2.x and Hibernate 3.5?

Does anyone know if Hibernate 3.5 is supported under Seam 2.x (specifically 2.2.x)? I'm very interested in some of the JPA 2 features, particularly query building, but work within the Seam framework. Is this version of the library supported? Thanks in advance! ...

JPA merge fails due to duplicate key

I have a simple entity, Code, that I need to persist to a MySQL database. public class Code implements Serializable { @Id private String key; private String description; ...getters and setters... } The user supplies a file full of key, description pairs which I read, convert to Code objects and then insert in a singl...

JPA Entity Manager resource handling

Every time I call JPA method its creating entity and binding query. My persistence properties are: <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/> <property name="hibernate.cache.provider_class" value="net.sf.ehcache.hibernate.SingletonEhCacheProvider"/> <property name="hibernate.cache.use_second_...