jpa

How to change Entity type in JPA?

In my specific case, I am making use of a discriminator column strategy. This means that my JPA implementation (Hibernate) creates a users table with a special DTYPE column. This column contains the class name of the entity. For example, my users table can have subclasses of TrialUser and PayingUser. These class names would be in the DTY...

Configuring setting for JPA

How can I configure Jetty to use Java Persistence API? I would prefer to use toplink-essentials. ...

Issue while getting the Hibernate EntityManagerFactory in Weblogic (EJB3 Application)

I am facing an issue when am getting the EntityManagerFactory from JPA from the following code in weblogic StartUp Class EntityManagerFactory emf = Persistence.createEntityManagerFactory("testEJBPU"); logger.info("Created EntityManagerFactory"); Context ctx = new InitialContext(); ctx.rebind("testEJBPU", emf...

Why do I get the error "Only antlib URIs can be located from the URI alone,not the URI" when trying to run hibernate tools in my build.xml

I'm trying to run hibernate tools in an ant build to generate ddl from my JPA annotations. Ant dies on the taskdef tag. I've tried with ant 1.7, 1.6.5, and 1.6 to no avail. I've tried both in eclipse and outside. I've tried including all the hbn jars in the hibernate-tools path and not. Note that I based my build file on this post: ...

How to map composite key of entity in JPA?

I have the REGION table: REG { id number, dateCreation Date } I have a LOCALE table: LOCALE { locale String } I have a REGION_DESCRIPTION table: REGION_DESCRIPTION { locale String, regId number, description } REGION_DESCRIPTION has a composite key: locale is a foreign key pointing to the LOCALE ...

Annotation a Map containig a non-entity class in JPA

Is it possible to use a map with a non-entity class in JPA? If yes, how should it be annotated correctly? @Entity class A { @HowShouldIAnnotateThis? private Map<B, Integer> myMap = new HashMap<B, Integer>(); } @Entity class B { ... } ...

How to use @BasicMap for a HashMap whose key values are entities

How should I use EclipseLink's @BasicMap annotation for a map whose key value is an entity and the value is an Integer? @Entity class A { // This doesn't work, as the key is an entity @BasicMap private Map<B, Integer> myMap = new HashMap<B, Integer>(); } @Entity class B { ... } ...

Container-managed EntityManager in Servlet

How to obtain? ...

EJB Find persisted data in single transaction

Let's say i have two tables in db: Car and Part. Car owns arbitrialy number of parts. Because i use EJB 3.0 i have entity beans for Car and Part and Car entity bean contains list of Part objects. I want to save new Part to db and right after that fetch from db all Cars. I exepect Part i've just added to be amongst parts associated with...

Hibernate/JPA inheritance issue on weblogic

Im getting a weird error when running my spring2.5.6,jpa(hibernate3.4) webapp in weblogic 10.3 [ERROR] Javassist Enhancement failed: com.xxx.domain.model.Scheme java.lang.NoSuchMethodError: pcGetManagedFieldCount at com.xxx.domain.model.Fund.<clinit>(Fund.java) at sun.misc.Unsafe.ensureClassInitialized(Native Method) ...

Groovy + JPA + Spring not working

I have the following java class: package domain; //imports @Entity public class User { @Id @GeneratedValue private long id; private String name; private String password; private String mail; //Getters, Setters and Constructors } When I change the file extension to .groovy, the application stops working. In ...

[Java] how to model a friends system with persistency layer?

Hi am i'm trying the new Java support for google app engine, and i am trying to make a persistency layer for all my objects. I am trying to model a friend connection but am running into problems. I use JPA to persist the objects and define my persistency objects with JPA annotations. My idea was to do the following: User Object: @E...

Hibernate using JPA (annotated Entities) and liquibase

liquibase is a perfect alternative to hibernate's hbm2ddl_auto property if you are using xml-mapping. But Im using JPA annotation (hibernate annotations). Is it possible to use liquibase then? ...

Reverse engineer DDL from JPA entities

I'm playing around with some JPA stuff, changing the mappings to see how they're supposed to be etc. It's basic experimentation. However I can't find a tool that will simply read my entities and then generate the table schema for me. I tried to find something like this in JBoss tools but nada. Eclipse integration will be a huge plus but ...

JPA/Hibernate bulk inserts slow

I'm doing bulk inserts with JPA using Hibernate as my provider. The DB is Oracle. It created a sequence generator, and each time it does an insert it queries the sequence generator for nextval. If I'm doing 1K inserts, it will hit the sequence generator 1K times. Any way to speed this up, if I want to stick with JPA? ...

noob project to learn Spring/Hibernate

I want to get my feet wet with Spring/Hibernate. But I think I move along faster and am more motivated if I am working with code rather than just reading a book chapter by chapter. Does anyone have any good ideas for a home project to work on to learn these technologies? Any exercises that you might have worked on and thought useful? O...

How to batch insert in specific order?

EntityManager doesn't seem to care in which order to persist entities but I need that. Any ideas? ...

JPA Hibernate One-to-One relationship

I have a one-to-one relationship but hibernatetool complains when generating the schema. Here's an example that shows the problem: @Entity public class Person { @Id public int id; @OneToOne public OtherInfo otherInfo; rest of attributes ... } Person has a one-to-one relationship with OtherInfo: @Entity public cl...

How do I get an auto-generated value?

@TableGenerator(name = "trial", table = "third", pkColumnName = "a" , valueColumnName = "b", pkColumnValue = "first") @Entity public class First{ @Id @GeneratedValue(strategy = GenerationType.TABLE, generator = "trial") protected int a; @OneToMany(mappedBy ="first", cascade = CascadeType.PERSIST) @JoinColu...

join by primary keys

I deal with legacy data base such that some tables joined on primary keys the following is a simple example: @TableGenerator(name = "trial", table = "third", pkColumnName = "a" , valueColumnName = "b", pkColumnValue = "first") @Entity public class First{ @Id @GeneratedValue(strategy = GenerationType.TABLE, generator...