jpa

NoViableAltException using jpa

Hi @all, i´ve got a problem to get jpa running. Following exception appears when i try to run the Login.java WicketMessage: Can't instantiate page using constructor public de.test.pages.LoginPage() Root cause: NoViableAltException(93!=[364:1: selectExpression returns [Object node] : (n= aggregateExpression | n= scalarE...

Hibernate/JPA: Mapping entities to different databases

Hi guys, I have an application which manages 3 databases. I use hibernate with JPA on seam framework. So I have a persitence.xml file with three persitence-unit like this (I remove properties for db2 and db3): <persistence-unit name="db1" transaction-type="JTA" > <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta...

How to apply a default-restriction on Entity-Bean @OneToMany Relationships

Dear all, I have to e ntity model like Customer and Order. Each customer could have thousand orders, well, I make OneToMany and ManyToOne relationship between these to entities. But the thing I want is how to restrict this relationship's list to only top 10 orders. I mean if it is possible to apply 'WHERE' condition as an attribute on @...

Unidirectional Relationship in Entity-Bean (JPA)

How to make Unidirectional Relationship in EJB 3.0 Entity-Beans (JPA)? For example Customer know about Order but Order has not any method for Customer. using (@OneToMany or @OneToOne or @ManyToMany) Regards ...

Moving a database with pg_dump and psql -U postgres db_name < ... results in "ERROR: relation "table_name" does not exist"

I moved my PostgresQL database from one hard drive to another using pg_dump -U postgres db_name > db_name.dump and then psql -U postgres db_name < db_name.dump I created the database db_name the same way in both instances. In the new database when I run my Java program with a JPA query (or a JDBC query) I get this error: "ERROR:...

How to find the version of JPA?

How to understand What JPA version I'm using in EJB? Is JPA built-in EJB? Regards ...

Maven and the " is not a known entity type" error

Hi everybody, I generated a maven project with the quickstart archetype. So I obtained the following project structure: |-- src | |-- main | | |-- java | | |-- resources | |-- test | | |-- java | | |-- resources |-- pom.xml I modified the "pom.xml" file : <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:...

How to use JPA EclipseLink to connect to the DB in a multi layer environment (REST + EJB + Core) ?

I am using Glassfish v3 server. Usually the DB connection with EJB3 + JPA (Eclipselink) is done through injection, with @PersistenceUnit or @Persistencecontext. However, there are 3 layers in my App : Core (contains business logic, entities, exception handling etc) an EJB on top of it, calling the right core objects and methods to do...

MEMBER OF in EJB-QL 3 doesn't work

Hi, I would like to retrieve many 'Access' which have one 'Role' in common. It's the Named Querie SELECT access FROM Access AS access WHERE :role MEMBER OF access.listRole The Access Entity public class Access implements Serializable { @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; private String...

JP QL - Filtering result in a One To Many relationship

I am stuck trying to construct a JPQL query and was hoping someone with more JPA experience than mine could help. Consider the following two entities: class Author{ String name @OneToMany(mappedBy="author") Set<Book> books } class Book{ String title Boolean inPrint @ManyToOne Author author } If I want to return a spec...

IBM Websphere JPA configuration - how to update persistence.xml

I'm new to EJB 3 and the JPA. I've created a datasource in the appserver which is jdbc/AppDataSource. The default persistence provider is left as com.ibm.websphere.persistence.PersistenceProviderImpl. And I left the default jta data source JNDI name as AppDataSource itself. I'm actually confused regarding JTA and non-JTA. What different...

entityManager.persist(user) -> javax.persistence.EntityExistsException: User@b3089 is already persistent

// lookup existing user & set a currently null child entity (ContactInfo) user.setContactInfo(contactInfo); // update the user in the datastore with newly created child Entity entityManager.persist(user); Generates exception: javax.persistence.EntityExistsException: User@b3089 is already persistent Since the user alrea...

Persistence deployment issue

I have a hibernate project, which uses JPA. my persistence.xml contents is as follows: <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"&gt;...

JPA Inheritance entitymanager.find produces ClassCastException

Hi, I have a class hierarchy like this: @Entity @Table (name="call_distribution_policies") @Inheritance (strategy=InheritanceType.JOINED) public class CallDistributionPolicy implements Serializable, Cloneable{ ---------------- } @Entity @Table(name="skill_based_call_distribution_policies") public class SkillBasedCallDistributionP...

JPA persist same entity twice

Hey guys, I just noticed that a part of code I worked on saves the same entity twice. I tried several tricks, like flush() and Transaction REQUIRES_NEW but nothing does it. But I can see while debugging that after calling persist(entity), I get an ID (IDENTITY) for that entity... but just a bit later in the code if I look at the variable...

HSQLDB and Hibernate/JPA - not persisting to disk?

Something of an novice with HSQL and Hibernate... em.getTransaction().begin(); for (Activity theActivity : activities) { em.persist(theActivity); } em.getTransaction().commit(); em.close(); followed by... EntityManager em = emf.createEntityManager(); em.getTransaction().begin(); System.out.println("QUERY:: " + em.createQuery("S...

AbstractWizardFormController: teasing command object

Hi Could I use a non-persistent domain object as a command object in spring mvc and have an instance of a persistent(made persistent using @Entity annotation in the domain class) object in it and have its (persistent object) data made persistant in a database? I am using AbstractWizardFormController for my application and it shows the ...

JPA composite foriegn key error

In my code there is a one-to-one relation between an employer and its rate table where the composite primary key of employer is composite foreign (logically)+primary key of rate . I am using JPA+hibernate+DB2. here is my employer.hbm file. <hibernate-mapping> <class name="com.adg.ems.domain.Employer" table="EMPLOYER"> </composite-...

Tips for Manually Managing Persistence Context

I am investigating using JPA for my Data Access code. I am trying to write the business layer and data access layer so it will work in a web application and a Java SE application. Therefore I cannot use container managed persistence context. Most of my seraches on using JPA show examples in a container managed enviroment. At the mome...

Hibernate: Query cache never used

Hi, During performing some performance tuning in my application I have noticed, that hibernate query cache is never used. I am quite sure I have it properly set up: hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider hibernate.cache.use_query_cache=true I use setCacheable(true) on queries I want to cache I have set u...