jpa

Detach an entity from JPA/EJB3 persistence context

What would be the easiest way to detach a specific JPA Entity Bean that was acquired through an EntityManager. Alternatively, could I have a query return detached objects in the first place so they would essentially act as 'read only'? The reason why I want to do this is becuase I want to modify the data within the bean - with in my app...

Enabling Hibernate second-level cache with JPA on JBoss 4.2

What are the steps required to enable Hibernate's second-level cache, when using the Java Persistence API (annotated entities)? How do I check that it's working? I'm using JBoss 4.2.2.GA. From the Hibernate documentation, it seems that I need to enable the cache and specify a cache provider in persistence.xml, like: <property name="hib...

Batch insert using JPA/Toplink

I have a web application that receives messages through an HTTP interface, e.g.: http://server/application?source=123&amp;destination=234&amp;text=hello This request contains the ID of the sender, the ID of the recipient and the text of the message. This message should be processed like: finding the matching User object for both th...

JEE SqlResultSetMapping Syntax problem?

I have the following Java 6 code: Query q = em.createNativeQuery( "select T.* " + "from Trip T join Itinerary I on (T.itinerary_id=I.id) " + "where I.launchDate between :start and :end " + "or ADDDATE(I.launchDate, I.equipmentPullDayOfTrip) between :start and :end", "TripResults" ); q.se...

Hibernate (JPA) how to do an eager query, loading all child objects

Relating to my earlier question, I want to ensure all the child objects are loaded as I have a multiple threads that may need to access the data (and thus avoid lazy loading exceptions). I understand the way to do this is to use the "fetch" keyword in the query (EJB QL). Like this: select distinct o from Order o left join fetch o.orde...

JPA Multiple Transaction Managers

i have one applicationContext.xml file, and it has two org.springframework.orm.jpa.JpaTransactionManager (each with its own persistence unit, different databases) configured in a Spring middleware custom application. i want to use annotation based transactions (@Transactional), to not mess around with TransactionStatus commit, save, and ...

persistence.xml not found during maven testing

I'm trying to load test data into a test DB during a maven build for integration testing. persistence.xml is being copied to target/test-classes/META-INF/ correctly, but I get this exception when the test is run. javax.persistence.PersistenceException: No Persistence provider for EntityManager named aimDatabase It looks like it...

Is there a Problem with JPA Entities, Oracle 10g and Calendar Type properties?

Hello, I'm experiencing the following very annoying behaviour when using JPA entitys in conjunction with Oracle 10g. Suppose you have the following entity. @Entity @Table(name = "T_Order") public class TOrder implements Serializable { private static final long serialVersionUID = 2235742302377173533L; @Id @GeneratedValue(...

Compound keys in JPA

I want to make an entity that has an autogenerated primary key, but also a unique compound key made up of two other fields. How do I do this in JPA? I want to do this because the primary key should be used as foreign key in another table and making it compound would not be good. In the following snippet, I need the command and model to ...

What are the best books for Hibernate & JPA?

My team is about to build a new product and we are using Hibernate/JPA as the persistence mechanism. There are other book posts on stackoverflow, but I couldn't find one that matched my needs. My manager will be purchasing books for our team to use as a resource so... What are the best books about Hibernate and JPA? (Please list each...

Which EJB 3 persisent provider should I use?

I are using EJB 3 on a fairly large J2EE project, by default with Netbeans sets the persistent provider for the entity beans to TopLink. There is the option to change the provider to one of the following or even add a new persistence library: Hibernate KODO OpenJPA Which persistence provider do you prefer to use? What are the benefit...

JPA 1 is not good enough

Working in a medium size project during last 4 months - we are using JPA and Spring - I'm quite sure that JPA is not powerfull for projects that requires more than CRUD screen... Query interface is poor, Hibernate doesn't respect JPA spec all the time and lot of times I need to use hibernate classes, annotations and config. What do ...

Can Seam 2.0.2sp1 apps run on Tomcat 5.5.9 with JBoss Embedded?

I'm trying to run the Tomcat with JBoss Embedded jpa booking example. I run the build and deploy the war. I then get the following error: ERROR [catalina.core.ContainerBase.[Catalina].[localhost].[/jboss-seam-jpa]] Error configuring application listener of class com.sun.faces.config.ConfigureListener java.lang.NoClassDefFoundError: j...

When to use Hibernate/JPA/Toplink?

Right now I'm making an extremely simple website- about 5 pages. Question is if it's overkill and worth the time to integrate some sort of database mapping solution or if it would be better to just use plain old JNDI. I'll have maybe a dozen things I need to read/write from the database. I guess I have a basic understanding of these tech...

Enterprise App and the Enterprise App Client

I came aboard a new project with a new company and we are trying to use JPA to do some DB work. So we have an Ear with an EJB, a webservice, and then there is a app client in the ear that really does all the work. The Webservice, calls the EJB, and the EJB calls the client to do the DB work. So within the appclient I want to load an E...

Another JPA Question

I have this code: @PersistenceContext(name="persistence/monkey", unitName="deltaflow-pu") ... @Stateless public class GahBean implements GahRemote { But when I use this: try{ InitialContext ic = new InitialContext(); System.out.println("Pissing me off * " + ic.lookup("java:comp/env/persistent/monkey")); Iterator e = ic.getEnvironm...

JPA annotations and Interfaces

I have a class Animal and an interface it inherits from IAnimal. @MappedSuperclass public class Animal implements Serializable, IAnimal{...}. @Entity public class Jaguar extends Animal{...} My first question is, do I need to annotate the interface? I asked this because I am getting this error when I run my tests: Error compiling...

Hibernate.initialize() and second-level cache

Does anybody know if Hibernate's static initialize() method, which populates a proxy object, will attempt to hit the second-level cache before going to the database? My code seems to be behaving that way, and I can't seem to find anything in the documentation about this. The Javadoc is (as usual) sparse. Thanks! ...

JPA - Unknown entity bean class

Hopefully, I can explain this issue properly. I have 3 classes that deals with my entities. @MappedSuperclass public abstract class Swab implements ISwab { ... private Collection<SwabAccounts> accounts; ... } @Entity @Table(name="switches") @DiscriminatorColumn(name="type") @DiscriminatorValue(value="DMS500") public class DmsSwab ...

JPA and 2 simple tables

I have 2 tables: A s_id(key) name cli type B sa_id(key) s_id user pwd So in Jpa I have: @Entity class A...{ @OneToMany(fetch=FetchType.EAGER) @JoinTable( name="A_B", joinColumns={@JoinColumn(name="a_id", table="a",unique=false)}, inverseJoinColumns={@JoinColumn(name="b_id", table="b", unique=true)} ) Collection getB...