jpa

How do I make JPA POJO classes + Netbeans forms play well together?

I started using netbeans to design forms to edit the instances of various classes I have made in a small app I am writing. Basically, the app starts, an initial set of objects is selected from the DB and presented in a list, then an item in the list can be selected for editing. When the editor comes up it has form fields for many of the ...

How to backup database to disk using JPA?

Hello, Which query to write in JPQL for backing up database on disk? If in JPQL it's not available even native sql query will do. Also, i would like to bring one issue in front of stackoverflow developers :- This site doesn't properly work in Opera (Opera 9.63). Whenever i write question and click "Post Your question" The button click e...

Dependency Injection with Spring/Junit/JPA

I'm trying to create JUnit tests for my JPA DAO classes, using Spring 2.5.6 and JUnit 4.8.1. My test case looks like this: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations={"classpath:config/jpaDaoTestsConfig.xml"} ) public class MenuItem_Junit4_JPATest extends BaseJPATestCase { private ApplicationContext c...

Dynamic JPA 2.0 query using Criteria API

Hello all, I am a bit stucked constructing a dynamic query using the CriteriaBuilder of JPA 2.0. I have quite a common use case I guess: User supplies a arbitrary amount of search parameters X to be and / or concatenated: like : select e from Foo where (name = X1 or name = X2 .. or name = Xn ) The Method or of CriteriaBuilder is no...

Inheritance concept in jpa

I created one table using Inheritance concept to sore data into google app engine datastore. It contained following coding but it shows error.How to user Inheritance concept.What error in my program Program 1: @Entity @Inheritance(strategy = InheritanceType.JOINED) public class calender { @Id private String EmailId; @Basi...

How to make an entity out of a join table without primary key

I'm trying to generate JPA entities out of an existing database having an "interesting" design. Database has a table called UserSet, which can have links to several other UserSets. There is a one to many relation between UserSets and LinkedUserSets. LinkedUserSets also has one to one relation to UserSets. I tried to generate a JPA Enti...

How to create a "facade" table?

A legacy database contains a join table which links tables table1 and table2, and contains just two foreign keys: TABLE_ORIG: table1_id table2_id In order to utilize this table using JPA I would need to create a surrogate primary key to the link table. However, the existing table must not be modified at all. I would like to create an...

Is it possible to build a JPA entity by extending a POJO?

Lets say I have the following POJO: public class MyThing { private int myNumber; private String myData; //assume getter/setter methods } Is it now possible to extend this POJO as a JPA entity? @Entity @Table(name = "my_thing") public class MyThingEntity extends MyThing implements Serializable { @Column(name = "my_number") //?????...

What is difference between @Resource UserTransaction and EntityManager.getTransaction()

Hello, Can anybody explain what is difference between : @Resource UserTransaction objUserTransaction; and EntityManager.getTransaction(); And also what is container managed transaction? and how should I do it in my session facade if I want to insert three rows in table in transaction. ...

Seam Gives Unknow Entity Exception For Entities in Jars

Hi, I am trying to use Seam to persist my jpa entities, when I reference an entity that is in a jar seam says unknown entity. I don't want to add all classes in persistence.xml I want seam to scan my jars and auto detect entities (as done by spring). what I miss? ...

Elegantly handling constraint violations in EJB/JPA environment?

I'm working with EJB and JPA on a Glassfish v3 app server. I have an Entity class where I'm forcing one of the fields to be unique with a @Column annotation. @Entity public class MyEntity implements Serializable { private String uniqueName; public MyEntity() { } @Column(unique = true, nullable = false) public Str...

JPA Problems mapping relationships

Hello. I have a problem when I try to persist my model. An exception is thrown when creating the EntityManagerFactory: Blockquote javax.persistence.PersistenceException: [PersistenceUnit: ASD] Unable to build EntityManagerFactory at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677) ...

Can Hibernate be used as the JPA provider in Google App Engine

Can Hibernate 3.5.x be used as the JPA provider instead of the default provider in the latest version of Google App Engine (1.3.2) ...

Error in Netbeans(?): attribute column name (length) is a reserved Java Persistence QL keyword

I have a column named length in an Oracle database. I cannot change the column name. When I use the @Column(name="length") in a JPA Entity I get the following error: attribute column name (length) is a reserved Java Persistence QL keyword I am using the Netbeans 6.8 IDE. Any ideas on this? Thanks ...

one-to-one relationship using JPA

I have created two table using JPA. i need to give 1-1 relationship between these tables. Can any one tell me how to give relationship between these tables. ...

where is the best palce to count the lazy load property using JPA

Let's say we have a "Question" and "Answer" entity, @Entity public class Question extends IdEntity { @Lob private String content; @Transient private int answerTotal; @OneToMany(fetch = FetchType.LAZY) private List<Answer> answers = new ArrayList<Answer>(); ...... I need to tell how many answers for the...

JPA: persisting object, parent is ok but child not updated

Hello, I have my domain object, Client, I've got a form on my JSP that is pre-populated with its data, I can take in amended values, and persist the object. Client has an abstract entity called MarketResearch, which is then extended by one of three more concrete sub-classes. I have a form to pre-populate some MarketResearch data, but ...

Help with JPQL query

I have to query a Message that is in a provided list of Groups and has not been Deactivated by the current user. Here is some pseudo code to illustrate the properties and entities: class Message { private int messageId; private String messageText; } class Group { private String groupId; private int messageId; } class Deactiva...

Does Hibernate 3.5.0-CR-2 release support JPA2.0

I see that Hibernate home page has a symbol informing that it implements JSR 317, but I couldn't find if it implements the full spec. Does anybody knows if Hibernate 3.5.0-CR-2 fully implements the JSR 317? I can see from their JIRA that everything is closed related to JPA 2.0: http://opensource.atlassian.com/projects/hibernate/browse/...

How to run Spring 3.0 PetClinic in tomcat with Hibernate backed JPA

OK, this probably is supposed to be the easiest thing in the world, but I've been trying for the entire day, and it's still not working.. Any help is highly appreciated! EDIT: For the correct procedure, please see Pascal's answer. My wrong (since I did not disabled LoadTimeWeaving) procedure is left for reference..: What I did: D...