jpa

JPA 2.0 Eclipse Link ... Composite primary keys

I have two entities(actually more but it doenst matter) Exam and Exam_Normals Its a oneToMany relationship... The problem is that i need a primary key for Exams_Normals PK (Exam_ID Item) Item should be 1 2 3 4 5 etc.... But cant achieve it getting errors An alternative would be to: I cound use an IDENTITY and a ManyToOne relationship ...

"Unknown database 'mydb' " error with jpa

hello, i'm trying to connect to mysql server but get this error. when mydb is the only name in the system. please tell me where i'm wrong... my persistence xml is as folow: <persistence 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/...

Nullable Date column merge problem

I am using JPA with openjpa implementation beneath, on a Geronimo application server. I am also using MySQL database. I have a problem with updating object with nullable Date property. When I'm trying to merge entity with Date property set to null, no sql update script is generated (or when other fields are modified, sql update script is...

How to do Grouping using JPA annotation with mapping given field

I am using JPA Annotation mapping with the table given below, but having problem that i am doing mapping on same table but on diffrent field given ProductImpl.java @Entity @Table(name = "Product") public class ProductImpl extends SimpleTagGroup implements Product { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private lo...

JPA behaviour...

Hi I have some trouble understanding a JPA behaviour. Mabye someone could give me a hint. Situation: Product entity: @Entity public class Product implements Serializable { ... @OneToMany(mappedBy="product", fetch=FetchType.EAGER) private List<ProductResource> productResources = new ArrayList<ProductResource>(); .... public List<Produ...

EclipseLink generates cartesian plan instead of (inner) joins in SQL. Why?

Hello again, In the projects where Hibernate is my persistence provider, I can issue queries with 'join fetch' expressions, and Hibernate will generate SQL that mirrors that: SQL containing join expressions using valid paths of comparison. EclipseLink, however, issues SQL with ugly cartesian plans, that hurt performance quite badly. Wh...

Pros & Cons: Hibernate vs. EJB 3

What are the advantages and disadvantages of Hibernate & EJB3 relative to each other? I found this post, but it didn't really address my question. If I don't have any particular tie to either technology, what would cause me to pick one over the other? Or are there situations where I would want to use both? Thanks, Zack edit: in respon...

after assembling jar - No Persistence provider for EntityManager named ....

im developing a standalone application and it works fine when starting it from my ide(intellij idea), but after creating an uberjar and start the application from it javax.persistence.spi.PersistenceProvider is thrown saying "No Persistence provider for EntityManager named testPU" here is my persistence.xml which is placed under meta-in...

Beginner question: basic insertion idiom for JPA?

My "HelloJPA" code (below) tries to store an Employee in a datastore. However, any attempt to read the persisted object after committing the (resource local) transaction is rewarded with an "IllegalStateException": Employee employee = ... EntityManagerFactory factory = Persistence.createEntityManagerFactory( "HelloJPA", System.getPr...

Random select rows via JPA

In Mysql, SELECT id FROM table ORDER BY RANDOM() LIMIT 5 this sql can select 5 random rows. How to do this via JPA Query (Hibernate as provider, Mysql database)? Thanks. ...

How to persist in order

I have two entities: EXAM and EXAM_NORMAL. EXAM @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private Long id; private String name; private String codeName; @Enumerated(EnumType.STRING) private ExamType examType; @ManyToOne private Category category; @OneToMany(mappedBy="id",cascade=CascadeTy...

JPQL TEMEDIFF equvalent

Is there an equvalent of SQL TEMEDIFF functionality in JPQL? Is that possible to query with JPQL to find the records in specific time range? ...

Google App Engine: JDO does the job, JPA does not

I have setup a project using both Jdo and Jpa. I used Jpa Annotation to Declare my Entity. Then I setup my testCases based on LocalTestHelper (from Google App Engine Documentation). When I run the test, a call to makePersistent of Jdo:PersistenceManager is perfectly OK; a call to persist of Jpa:EntityManager raised an error: java.lang....

Tomcat 6, JPA and Data sources

Hi there, I'm trying to get a data source working in my jsf app. I defined the data source in my web-apps context.xml webapp/META-INF/context.xml <?xml version="1.0" encoding="UTF-8"?> <Context antiJARLocking="true" path="/Sale"> <Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxActive="20" maxIdle="10"...

Problem with bidirection ManyToOne

I have two entities: Message and GeneratedMemberMessage. There are more fields than I'll show in code here, but these should provide enough for context to my question. I'm trying to do a simple bidirectional OneToMany relationship and from all that I've read, this is how it's to be done. You'll notice that I'm using composite keys. ...

JPA: @ElementCollection and InheritanceType.TABLE_PER_CLASS -> Duplicate column name

I've created the following scenario: @javax.persistence.Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public class MyEntity implements Serializable{ @Id @GeneratedValue protected Long id; ... @ElementCollection @CollectionTable(name="ENTITY_PARAMS") @MapKeyColumn (name = "ENTITY_KEY") @C...

JPA concatenating table names for parent/child @OneToMany

We are trying to use a basic @OneToMany relationship: @Entity @Table(name = "PARENT_MESSAGE") public class ParentMessage { @Id @Column(name = "PARENT_ID") @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer parentId; @OneToMany(mappedBy="parentMsg",fetch=FetchType.LAZY) private List childMessages; public List g...

Tips for resolving Hibernate/JPA EntityNotFoundException

I'm running into a problem with Hibernate where when trying to delete a group of Entities I encounter the following error: javax.persistence.EntityNotFoundException: deleted entity passed to persist: [com.locuslive.odyssey.entity.FreightInvoiceLine#<null>] These are not normally so difficult to track down as they are usually caused by ...

hibernate update JPA foreign key

My jpa looks like below public class TESTClass implements Serializable { ... private String name; @EmbeddedId protected IssTESTPK issTESTPK; @ManyToOne(optional=false) @JoinColumns({ @JoinColumn(name="DIVISION_CODE", referencedColumnName="DIVISION_CODE", nullable=false, insertable=false, updatable=fal...

Performing static SQL queries against DB2 without PureQuery

I'd like to use JPA over JDBC for a new application. I'm strictly using Named queries and basic CRUD methods of JPA Entity manager, which allows me (with the help of Hibernate, or any other JPA implementation) to extract all SQL native queries that will be performed on the database. With this list of static queries, I understand that I c...