jpa

How to avoid blocking EDT with JPA lazy loading in Swing desktop apps

I'm struggling with real-world use of JPA (Hibernate, EclipseLink, etc) in a Swing desktop application. JPA seems like a great idea, but relies on lazy loading for efficiency. Lazy loading requires the entity manager exist for the lifetime of the entity beans, and offers no control over what thread is used for loading or any way to do t...

Is Hibernate deprecated?

Hi folks, this morning I was aboard a S-Bahn (German Subway) and I met a fellow student, who works for IBM. What he is doing there is JEE optimization. I told him about my little project. And he recommended not to use 'oldschool' hibernate. That's why my question is: Is Hibernate deprecated? (In combination with JEE/Web Development) ...

JPA native query and cache

Hi All, Does native query in JPA (createNativeQuery) supports caching? I am filling my own data transfer object because the sql query joins several tables and takes only several columns form them. Regards ...

JPA Entities with JoinColumn of two columns

I have this escenario... I have three 4 entities {orderItem, suppliers, supplier, prices}, and they are related like: OrderItem 1->* suppliers (some one item can have many supplier prices) Suppliers 1->1 supplier Suppliers 1->1 itemPrices and it's properties OrderItem {orderId, partId, quantity, suppliers} Suppliers {orderId, part...

Cannot delete or update a parent row - JPA with Hibernate

I have a database in which all of the tables have been generated by Java JPA/Hibernate code. I need to update several tables in my database in a fashion similar to this, UPDATE Department SET id=100000 WHERE id=0; Unfortunately this results in the error ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constr...

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...

SqlResultSetMapping with self join table

I have a query with a self join that looks like this, select t1., t2. from table t1 left outer join table t2 on t2.LFT < t1.LFT and t2.RGT > t1.RGT AND t2.REG_CODE_PAR = 'ALL' AND t1.STATUS_CODE = 'A' AND t2.STATUS_CODE = 'A' I'm using @NamedNativeQuery with a result set mapping to get the result. @NamedNativeQuery( name="fin...

@OneToMany does not insert foriegn key in Hibernate+JPA

Hi folks, I am facing some strange issue, I have a user table(use class) and a country table(country class). An user may have N number of countries. Hence, I have added a List of countries in the user class with the getter and setter method. In the table I have made the country_id as foreign key in user table. And, I have a @OneToMany o...

query results are not found in cache

Env: JBoss 5.1, ehcache 2.1.0, hibernate 3.3.x, seam 2.2.0 ehcache.xml (2.1.0 version) contains the following lines, but my query results are not found in cache. Am I supposed to set a cache region for each of the queries which are fired. What am I missing here? <!-- Cache configuration --> <cache name="org.hibernate.cache.UpdateTimest...

Single persistence unit for a modular application (JPA)

I want to create a modular(plugin-like) application that uses JPA as its persistence abstraction, and this application should be extensible by third parties. The catch is that I want this application and its plugins to be easily portable to other databases/JPA providers, so the third party vendors can't know anything about the used JPA p...

JPA Entity Validation

Ok, I'm trying to setup an application in a Java EE Container. I use JPA for persistence and I also use the javax.validation.constraints.* constraints. By default the container validate the entities during the @PrePersist and @PreUpdate lifecycle events and it's good for me, but how do I handle the ConstraintViolationException? I can't...

jpa hibernate composite foreign key mapping

I am having trouble setting up jpa mappings for some entities. I have a parent entity defined like the following. @Entity @Table(name="EIF_INSTANCE_HDR") public class InstanceEntity implements Serializable{ private static final long serialVersionUID = 1L; @Id @GeneratedValue(generator="eif_inst_gen") @SequenceGenerator(name="eif_inst...

Hibernate JPA, Spring MVC and LazyInitializationException

Hi All When trying to get items from db, I got this error: 13:00:13.876 [7838526@qtp-204712603-0] ERROR o.h.LazyInitializationException - failed to lazily initialize a collection of role: bo.myobj, no session or session was closed org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: de.myob.linke...

DataNucleus and Cache Coordination

Does DataNucleus support Cache Coordination? If yes, how can I enable and use it? I'm not actively using DataNucleus yet, but I want to consider it, if it supports Cache Coordination. Background: Cache coordination is used by multiple cache instances to inform each other about changed entities (e. g. via JMS or RMI). Its purpose is to ...

What is the difference between @ManyToOne(optional=false) vs. @Column(nullable=false)

In JPA, I am confused when to use the attribute optional=false and the annotation @column(nullable=false). What is the difference? ...

How to get field joined by third table in JPA.

I have 3 tables: object with object_id and field_name object_form with object_id and form_id and object_fields with form_id and field_desc So I can get all the objects with field_names, but I need to get field_desc. In SQL it would be something like: select o.object_id, f.field_desc from object o, object_form of, object_fields f wh...

GWT with JPA and Gilead example

Can someone please provide me an example of GWT + JPA + Gilead, I can't seem to find anything on Google with this topic. Thanks ...

How to install JPA persistence provider in spring roo project?

Hi guys! I am looking SpringSource Tool Suite with Google Integration and I am getting that hint when I define persistence setup. hint:"Command 'persistence setup --provider DATANUCLEUS --database HYPERSONIC_IN_MEMORY' was found but is not currently available (type 'help' then ENTER to learn about this command)"... and help is saying ...

Setting subclass primary key as auto_increment using JPA 2 annotations

Hi. I'm trying to generate a database schema for my project using hbm2ddl. I'm using JPA 2 annotations to specify how the schema should look like. Right now I'm having some issues with inherited id's. I have an abstract super class, let's call it AbstractSuperClass, which looks like this: @Entity @Inheritance(strategy=InheritanceType....

How to verify whether a record with certain field values exists in a DB with JPA?

How to express the exists clause with JPA? ...