jpa

Referencing a JPA project from an Eclipse Plugin results in "PersistenceException: No Persistence provider for EntityManager"

I am trying to create an Eclipse application that uses JPA for persistence. I am trying to use EclipseLink as my provider (more specific org.eclipse.persistence.jpa.PersistenceProvider) and Derby as my database. Currently I have an Eclipse JPA Project that deals with all the database communication and defines the model entities. This pro...

Help with a reusable JPA transaction method w/ rollback

I am retro-fitting transaction rollback support to a JPA-based java application, and am using Ecmel Ercans's approach to handling rollback (http://weblogs.java.net/blog/davidvc/archive/2007/04/jpa_and_rollbac.html) and JPA's kinks connected to rollbacks. It looks something like this: EntityManager em = emf.createEntityManager(); EntityT...

GAE unowned JPA relationship

I have an unowned relationship in my Domain model @Entity public class A { @Id private String id; private Key firstB; private Key secondB; // getters & setters } @Entity public class B { @Id private Key id; private String name; // getter & setter } KeyFactory.createKey(B.class.getSimpleName(), name) is the way I generate th...

Automatically apply field conversion function in Hibernate

I have a database table with a field that I need to read from and write to via Hibernate. It is string field, but the contents are encrypted. And for various reasons (e.g. a need to sort the plain text values), the encrypt/decrypt functions are implemented inside the database, not in Java. The problem I'm struggling with now is finding ...

Best Persistence API for use with GWT

What is the best persistence API for use with GWT? Sadly, the application will be hosted on my own java server, as I will need more control than GAE will give me. I know I will need to have two sets of my entities, one for the server side, and some pojo's for the client side. I'm looking to make the mapping of the data as simple as...

How do I prevent JPA inserts from locking a database table?

I'm using Hibernate backed JPA as my persistence layer. I have a multi-threaded process that aggregates data from a Soap call and then stores a row in a database. The process usually ends up inserting about 700 rows and takes about 1 - 3 hours, with the Soap calls being the main bottleneck. During this entire process the table I am ins...

How can I merge / extend persistence units from different JARs?

I use JPA persistence for my data models with Eclipselink as the persistence provider. I have a modular (OSGi) application and one of the modules contains the standard data model and a persistence unit that automatically includes all the entities from the package. The persistence provider is in another module, which works well. Now I wa...

In class without a property called "type" I get org.hibernate.PropertyNotFoundException: Could not find a setter for property type in class

Using JPA, and Hibernate as the provideer, I have a class defined like: @Entity @Table(name="partyrole") public class PartyRole extends BaseDateRangeModel { private static final long serialVersionUID = 1L; private Party roleFor; public void setRoleFor(Party roleFor) { this.roleFor = roleFor; } @ManyToOne public Party g...

How can one debug/fix an everlasting null return from EntityManager's find?

Hello! I am following this example . I keep getting this error whenever calling upon find: java.lang.NullPointerException at LoginAction.service(LoginAction.java:41) at Dispatcher.doWork(Dispatcher.java:82) at Dispatcher.doGet(Dispatcher.java:64) at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) at javax...

How can I define a foreign key using netbeans 6.7?

I'm using JPA in netbeans with mysql and I need to define a foreign key. I want to do it graphically because it is very easy to create tables using netbeans 6.7 UI without dealing with SQL commands. Can you tell me how to do it?? ...

Mapping a ManyToMany across join/link table using 3 ID Fields

Is it possible to use a @ManyToMany mapping across a join using 3 PK columns? I'm fairly certain this is not possible and the solution is to expose the entity using @OneToMany which I have done in the past, but because this field is simply a PK I thought there maybe some clever mapping to save me this work. Regards a Hopeful - JamesC ...

How to have a @OneToMany relationship with its own entity?

I have items that can contain further items, therefore I need a @OneToMany relationship with the same Entity. I have configured my field like this: @ManyToOne(targetEntity=PersistentItem.class, fetch=FetchType.EAGER) @JoinColumn(name="ID_CHILDREN", nullable=false) HashSet<PersistentItem> children=new HashSet<PersistentItem>(); However...

How to specify a different column for a @Inheritance JPA annotation

@Entity @Inheritance(strategy = InheritanceType.JOINED) public class Foo @Entity @Inheritance(strategy = InheritanceType.JOINED) public class BarFoo extends Foo mysql> desc foo; +---------------+-------------+ | Field | Type | +---------------+-------------+ | id | int | +---------------+-----------...

JPA EntityManager deletes all records in database

I have one Servlet that does insertion into my database. This is working fine. A second Servlet displays what the first one has inserted, however whenever I run the displaying Servlet, all records in all my tables are being deleted! My JPA implementation is EclipseLink and the db is MySQL. Is it possible that the way I retrieve a Entity...

JPA + Hibernate + autocommit

Does anybody know why I get this warning when I turn off the auto-commit in JPA configuration file? Using this setting : <property name="hibernate.connection.autocommit" value="false"/> generates this warning : 2009-08-04 09:54:10,621 [main] WARN org.hibernate.ejb.Ejb3Configuration - hibernate.connection.autocommit = false break the...

Spring Open JPA

Hi, I am trying to integrate Spring and OpenJpa. For every scenario the exception thrown is SAXParseException: No Content allowed in Prolog. I am aware that the issue is probably related to the xml files but all the related xmls are read and validated correctly. The spring files are parsed correctly and beans are created but the en...

JPA-based JUnit Test Best Practices

This is a bit of an odd question, but it has been bothering me for a few months now. I have built a JPA-based web application using Wicket + Hibernate (built with Maven), and want to test the DAO layer directly. I created a specific src/test/resources/META-INF/persistence.xml file that I used for testing, but have been running into confl...

Debugging a MySQL charset error

I have a project where I scrape some data from a HTML file, put it into a MySQL database and then read it out again and display it to the user. Whenever the servlet is inserting something into the DB the "£" sign is being inserted as a � and when read out again presented as that. The application is written in Java (with Spring) and JPA ...

How to do selective @PostUpdate in JPA.

I have a child entity say X whose parent is say Y. X has @PostUpdate defined for it. say i remove 'X' from it's parent Y but do not delete X in itself. I reattach 'X' to 'Y' causing X's @PostUpdate to be called. I do not want to call it in this case. Is there any way I can stop it from happening ...

How can I leverage JPA when code is generated?

I have classes for entities like Customer, InternalCustomer, ExternalCustomer (with the appropriate inheritance) generated from an xml schema. I would like to use JPA (suggest specific implementation in your answer if relevant) to persist objects from these classes but I can't annotate them since they are generated and when I change the ...