jpa

Integrating GWT, Spring and JPA (Eclipse-link) in Weblogic 10

Hi, My application architecture looks like this. GWT in the UI layer -> Calls GWT RPC service (servlets) -> Looksup Spring Beans -> Calls the DAO layer which is implemented in JPA (EclipseLink). I have successfully tested the application with GWT rpc services directly calling the JPA layer. But I am having trouble integrating spring ...

Detach an entity from a JPA persistence context (JPA 2.0 / Hibernate / EJB 3 / J2EE 6)

Hi, I wrote a stateless EJB method allowing to get an entity in "read-only" mode. The way to do this is to get the entity with the EntityManager then detach it (using the JPA 2.0 EntityManager). My code is the following: @PersistenceContext private EntityManager entityManager; public T getEntity(int entityId, Class<T> specificClass,...

How to do a timestamp comparison with JPA query?

We need to make sure only results within the last 30 days are returned for a JPQL query. An example follows: Date now = new Date(); Timestamp thirtyDaysAgo = new Timestamp(now.getTime() - 86400000*30); Query query = em.createQuery( "SELECT msg FROM Message msg "+ "WHERE msg.targetTime < CURRENT_TIMESTAMP AND msg.targetTime > {ts, '...

What is the difference between Transaction-scoped Persistence context and Extended Persistence context ??

What is the difference between Transaction-scoped Persistence context and Extended Persistence context ?? ...

How can I implement a proper counter bean with EJB 3.0?

[EDIT] This question is "how do I do atomic changes to entity beans with EJB 3 and JPA 2.0". Should be simple, right? I tried to fix my code based on the answers I got so far. I'm using JBoss 6.0.0M2 with Hypersonic (just download it and call run.bat). My test case: Create 3 threads and call one of the testCounterMitLock*() 500 times i...

@OneToMany property null in Entity after (second) merge

Hi, I'm using JPA (with Hibernate) and Gilead in a GWT project. On the server side I have this method and I'm calling this method twice with the same "campaign". On the second call it throws a null pointer exception in line 4 "campaign.getTextAds()" public List<WrapperTextAd> getTextAds(WrapperCampaign campaign) { campaign = em.merge...

@PrePersist with entity inheritance

I'm having some problems with inheritance and the @PrePersist annotation. My source code looks like the following: _the 'base' class with the annotated updateDates() method: @javax.persistence.Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public class Base implements Serializable{ ... @Id @GeneratedValue...

Finding users whose birtday is today with JPA

Hi, I have a table with users and are trying to get a list with the people who have birthday today so the app can send an email. The User is defined as @Entity public class User { @Size(max = 30) @NotNull private String name; [...] @Temporal(TemporalType.DATE) @DateTimeFormat(style = "S-") protected Date ...

Java Persistence API

I am new to Java Persistence API. I have just learnt it and now want to use it in my Java Desktop Application. But I have the following questions regarding it: Q1. Which JPA implementation is smallest in size (as I want to have my application's size as small as possible)? Q2. How to find the value of the <provider> tag in the persisten...

Hibernate or JPA or JDBC or ???

I am developing a Java Desktop Application but have some confusions in choosing a technology for my persistence layer. Till now, I have been using JDBC for DB operations. Now, Recently I learnt Hibernate and JPA but still I am a novice on these technologies. Now my question is What to use for my Java Desktop Application from the fol...

JPA - Entity design problem

I am developing a Java Desktop Application and using JPA for persistence. I have a problem mentioned below: I have two entities: Country City Country has the following attribute: CountryName (PK) City has the following attribute: CityName Now as there can be two cities with same name in two different countries, the primaryKe...

What's difference between primitive and wrapper class in JPA (Hibernate) column mappings?

For instance, there’s an integer column in a database table. Then in java model, it can be mapped both as primitive int and Integer. My question is what's difference between the int and Integer in this case? And performance concern? Thanks! ...

Alternative of JPA

I want to use JPA for my persistence layer of my Java Desktop Application but I have the similar problem as describe at http://stackoverflow.com/questions/2562746/jpa-entity-design-problem/2563009#2563009 I didn't find a solution to the above kind of problem that's why I want to go with any other alternative of JPA. It would be better ...

hibernate or eclipselink?

It seems like EclipseLink has been chosen by sun as the reference implementation of JPA 2.0, nevertheless I see lots of people continue to use hibernate... I have no experience with any of them, so I wonder which one should I choose for a new project... I'd like to know the pros / cons of each one... thanks a lot ps: btw, and this is...

Invalid XML in persistence.xml : Init method

I'm getting the following error when I try to startup my application on google app engine: Failed startup of context com.google.apphosting.utils.jetty.RuntimeAppEngineWebAppContext@8fcc7b{/,/base/data/home/apps/sales-tracker/3.340980411948080671} org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cli...

struts 2 bean is not created

Hello colleagues! At first some precondition to my question, I'm using struts2 + tiles2 + toplink. NO spring at all. The simplest scenario - is to display list of entities on the page. To optimize resolving JPA's EntityManager I would like to create helper (JPAResourceBean) that implements lazy load of entity manager. For this purposes ...

Maven building for GoogleAppEngine, forced to include JDO libraries?

Hi, I'm trying to build my application for GoogleAppEngine using maven. I've added the following to my pom which should "enhance" my classes after building, as suggested on the DataNucleus documentation <plugin> <groupId>org.datanucleus</groupId> <artifactId>maven-datanucleus-plugin</artifactId> ...

Java - JPA - @Version annotation

I am new to JPA. I am cofused about the @Version annotation. How it works? I have googled it and found various answers whose extract is as follows: JPA uses a version field in your entities to detect concurrent modifications to the same datastore record. When the JPA runtime detects an attempt to concurrently modify the same reco...

JAX-WS and JPA, how to load stub objects using JPA?

I'm trying to develope a soap web service that has to access a mysql db. I have to replicate an existing service, so I created all the stub object from it's wsdl file Netbeans created all the necessary stuff for me (new, web service from wsdl), it works ok... Now I'm trying to use JPA to load all those objects from the database. So f...

Why JPA injection not works on @PersistentUnit

Hello colleagues! It is continues of question ( http://stackoverflow.com/questions/2570976/struts-2-bean-is-not-created ) I'm using struts2 + toplink in my very simple web application under Tomcat. On the page I would like use iteration tag. That is why I've declared some factory (SomeFactory) that resolves collection of entities (Enti...