jpa

How is my id being generated with JPA using Hibernate with the Oracle 10g dialect?

I have some code: @Id @SequenceGenerator(name = "SOMETHING_SEQ") @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SOMETHING_SEQ") @Column(name = "SOMETHING", nullable = false) private Long id; How is hibernate providing my id? I see in my database there a single sequence named 'hibernate_sequence' and no other hibern...

JPA + Hibernate + Native Query + custom list of dtos from the resultset

Hi, My native query below is working fine oracle sqlplus. But through JPA native query, giving following error: [ERROR] org.hibernate.util.JDBCExceptionReporter - ORA-00923: FROM keyword not found where expected Native Query SELECT sch.school_name, term.term_name, count(material.MATERIAL_ID), sip.SIP_COUNT, ... FROM VA_SCHOOL sch ...

Problem on jboss lookup entitymanager

I have my ear-project deployed in jboss 5.1GA. From webapp i don't have problem, the lookup of my ejb3 work fine! es: ShoppingCart sc= (ShoppingCart) (new InitialContext()).lookup("idelivery-ear-1.0/ShoppingCartBean/remote"); also the iniection of my EntityManager work fine! @PersistenceContext private EntityManager manager; Fr...

JPA exception: Object: ... is not a known entity type.

I'm new to JPA and I'm having problems with the autogeneration of primary key values. I have the following entity: package jpatest.entities; import java.io.Serializable; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; @Entity public class ...

JPA and hibernate for Flex

I'm using JPA but I'm not sure how to use it for relation between two classes. I need to connect them @OneToMany. I have done this before but forgot. Is there any good tutorial for this or an example that is easy to understand. By the way this is a Flex application where I'm using BlazeDS for connection between Java and Flex. ...

Insert 'Text' field data type into MySQL using EJB 3

private String message = ""; public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } I am using EJB3 and MySQL 5.1 using Java. I want to insert paragraphs of texts into MySQL Database using Entity Bean. But, When I add, MySQL can accept only 255 characters. It shows m...

Optimizations employed by ORM's

I'm teaching JEE, especially JPA, Spring and Spring MVC. As I have not so much experience in large projects, it is difficult to know what to present to students about optimisation of ORM. At the present time, I present some classic optimisation tricks: prepared statements (most of ORM implicitely use them by default) first and second-...

JPA and GWT failing.

I'm trying to use JPA with GWT. My serviceImpl calls UserDAO.exists(user); When I run a test case, which calls the same method, with the same parameters, it runs ok. When I do the RPC call, if fails horribly (error at the end). When I rename persistence.xml to someothername.xml, I get the SAME error, so I'm inclined to think that GW...

What exceptions are thrown by JPA in ejb containers?

I am developing an EJB application to run on glassfish v3. If I look at the javadoc for the EntityManager class it says that methods like find, persist etc throw exceptions derived from PersistenceException. However, in practice I notice that exceptions derived from org.eclipse.persistence.exceptions.DatabaseException can be thrown if so...

Classpath entry eclipse.fproj.jdt.libprov.osgi/jpt.jpa is marked for publish/export but is not exported on the project classpath

I'm trying to get a new Enterprise Application Project set up in Eclipse using Glassfish as my app server and I'm seeing the following warning: Classpath entry eclipse.fproj.jdt.libprov.osgi/jpt.jpa is marked for publish/export but is not exported on the project classpath. Classpath visibility within Eclipse and at runtime will differ. ...

Eclipse Galileo + Glassfish v3: JPADeployer NullPointerException on deploy

I've created a very simple "Enterprise Application" project with about 7 entity beans and one stateless session bean. I've also configured an instance of Glassfish v3 to run as my application server. Unfortunately, when I attempt to publish the EAR to Glassfish, I'm getting the following response: SEVERE: Exception while invoking class...

Is it okay to pass injected EntityManagers to EJB bean's helper classes and use it?

We have some JavaEE5 stateless EJB bean that passes the injected EntityManager to its helpers. Is this safe? It has worked well until now, but I found out some Oracle document that states its implementation of EntityManager is thread-safe. Now I wonder whether the reason we did not have issues until now, was only because the implement...

Invalidating JPA EntityManager session

A project I am working on uses Spring 2.5 & JPA with Hibernate as a provider. My DAO classes extend JpaDaoSupport, so I get my JpaTemplate using the getJpaTemplate() method. The back-end database can get changed either by my application, or a third-party application. When a third-party application changes the database (mostly config...

How to store Java Date to Mysql datetime...?

can any body tell me how can i store Java Date to Mysql datetime...? when i am trying to do so...only date is stored and time remain 00:00:00 in mysql date stores like this... 2009-09-22 00:00:00 i want not only date but also time...like 2009-09-22 08:08:11 please help me.... EDIT---- i am using JPA(Hibernate) with spring mydomain cl...

In Seam what's the difference between injected EntityManager and getEntityManager from EntityHome

I am testing a Seam application using the needle test API. In my code I am using the getEntityManager() method from EntityHome. When I run the unit tests against an in memory database I get the following exception: java.lang.IllegalStateException: No application context active at org.jboss.seam.Component.forName(Component.java:1945) at ...

Configuring JPA and JOTM without Spring

Can anyone point me to an example of configuring JPA/JOTM in an environment where Spring isn't being used? I'm building a web-app with Tomcat and JPA/MySQL. Currently I'm just using the RESOURCE_LOCAL transactions in the JPA persistence unit, but I'd like to move to a real transaction manager (JOTM) if possible. I've looked all over t...

use of EntityManagerFactory causing duplicate primary key exceptions

Hey guys, my goal is create an EntityManager using properties dependent on which database is in use. I've seen something like this done in all my Google searches(I made the code more basic for the purpose of this question): @PersistenceUnit private EntityManagerFactory emf; private EntityManager em; private Properties props; @PostCon...

Using Hibernate Validator with JPA and Spring

I'm using Hibernate Validator 4.0.2, Spring 3.0 and Hibernate 3.3.2 (which, as I understand it, is pre-JPA2) as a JPA 1 provider. I've found it easy to integrate the Validator into the MVC layer (it just works) but can't see how to integrate the validator automatically into the JPA entityManager (JPA 1). Basically, I have some entities...

The same objects in JPA

Hello, I have entity model like this (using EclipseLink and JPA 2.0): @Entity class A { @Id @GeneratedValue(strategy = GenerationType.AUTO) Long id; //equals, hashCode autogenerated by nb. } And: @Entity class B { @Id @GeneratedValue(strategy = GenerationType.AUTO)...

Using a Hibernate MapKey that's not unique within a table

This is a Hibernate/JPA question. I have a set of Schedule objects, each including several Steps of various StepTypes. Each StepType is unique within a schedule, so the steps are stored as a Map<StepType, Step>. The code is annotated as: @Entity public class Schedule implements Serializable { @MapKey(name="type") @OneToMany(c...