jpa

Combine two or more persistence.xml(s) into one , when packaging (war) many modules (Maven)

I have a maven-managed project with some modules (with jar package) , each module contains its "persistence.xml" in its META-INF directory. Another module take responsibilities to package these modules into a war file . But I find no way to "combine" these "persistence.xml" into one file ... Is it possible ? Thanks in advanced. ...

copy child collection to another object

Hi everyone, I have a one-to-many relationship between Part and Params (a "Part" has many "Params). I'm trying to do something naive like this: Part sourcePart = em.find(Part.class, partIdSource); Part destPart = em.find(Part.class, partIdDest); Collection<Param> paramListSource = sourcePart.getParamList(); destPart.setParamList(par...

JPA vs. JDBC, stored procedures and Co. or How to convince old school programmer to try ORM?

This is something I deal periodically with, and first time it was me who needed conviction. Luckily, I just tried, made extra effort to learn and thanks to this book, Spring support, and Hibernate I won't start a project without considering JPA. But not everyone is willing to go extra mile that often (just in anything we deal with I gues...

jpa-Google app engine

I had created entity in google app engie datastore using JPA. I set the id as follows @Id @GeneratedValue(strategy=GenerationType.SEQUENCE) private Long s; After i deployed my applicaiton it give identity (i.e) unique value.but igive 1001,1002,1003 ....as id.But i wnat 1,2,3,4,5 like that.how to achive this? ...

jpa-Primarykey relationship

Hi created student entity in gogole app engine datastore using JPA. Student--->Coding @Entity @Table(name="StudentPersonalDetails", schema="PUBLIC") public class StudentPersonalDetails { @Id @Column(name = "STUDENTNO") private Long stuno; @Basic @Column(name = "STUDENTNAME") private String stuname; public void se...

unique constraints-Google app engine

Is google app engine datastore support unique constraints? Thanks in advance ...

deadline in google app engine application

How to define deadline for google app engine datastore application using JPA thanks in advance ...

How to configure DB connection in a Servlet based JPA application

By default DB connections of JPA applications are configured in the META-INF/persistence.xml, when the application is not deployed to a full Java EE application server. In my opinion it is not very elegant to place such environment specific configuration into a file that is inside a .war file. How could a DB connection of a Servlet based...

Could not synchronize database state with session

Hello all, I'm having trouble trying to persist an entity which ID is a generated value. This entity (A), at persistence time, has to persist in cascade another entity(B). The relationship within A and B is OneToMany, and the property related in B is part of a composite key. I'm using Eclipse, JBOSS Runtime, JPA/Hibernate Here is my c...

Calculated property with JPA / Hibernate

My Java bean has a childCount property. This property is not mapped to a database column. Instead, it should be calculated by the database with a COUNT() function operating on the join of my Java bean and its children. It would be even better if this property could be calculated on demand / "lazily", but this is not mandatory. In the wo...

JPA/JDO entity to XML XSD generator.

I am using JDO or JPA on GAE plugin in Eclipse. I am using smartgwt datasource, accepting an xsd. I would like to be educated how to generate an XSD from my jdo/jpa entity, vice versa. Is there a tool to do it? While datanucleas does all its magic enhancing in the Eclipse background, would I be able to somehow operate in a mode that w...

Map null column as 0 in a legacy database (JPA)

Using Play! framework and it's JPASupport class I have run into a problem with a legacy database. I have the following class: @Entity @Table(name="product_catalog") public class ProductCatalog extends JPASupport { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) public Integer product_catalog; @OneToOne @Jo...

How to create an entity with a composite primary key containing a generated value.

Using Hibernate + annotations, I'm trying to do the following: Two entities, Entity1 and Entity2. Entity1 contains a simple generated value primary key. Entity2 primary key is composed by a simple generated value + the id of entity one (with a many to one relationship) Unfortunately, I can't make it work. Here is an excerpt of the ...

Difference between FetchType LAZY and EAGER in Java persistence?

Hi I am a newbie to Java persistence and Hibernate. What is the difference between FetchType LAZY and EAGER in Java persistence? Thanks ...

JPA atomic query/save for multithreaded app

I am in the midst of changing my JPA code around to make use of threads. I have a separate entity manager and transaction for each thread. What I used to have (for the single threaded environment) was code like: // get object from the entity manager X x = getObjectX(jpaQuery); if(x == null) { x = new X(); x.setVariable(foo); ...

Query Level 2 Caching throwing ClassCastException

Hi, I am using JPA and Hibernate for the database. I have configured (EHCacache) second level cache and query level cache, but just to make sure that caching is working I was trying to get the statistics which is throwing class cast exception.Any help will be highly appreciated. My main goal is to see all the objects which have been ca...

JPA/Hibernate Polymorphic Query with @Any

Hi there, I have a jpa mapping class with a polymorphic association like the following: @Entity class MyEnt { private Long id; private MyInterface mi1; private MyInterface mi2; //... @Any(metaColumn = @Column(name = "mi1_type")) @AnyMetaDef(idType = "long", metaType = "string", metaValues = { @MetaValue(valu...

HyperJAXB and IDREFs

I have eventually managed to fiddle HyperJAXB so that when XSD has complexType A and this has an IDREF to complexType B, then HyperJAXB will generate @OneToOne JPA annotations between the the two generated entities. However now I'm facing another problem: the XSD has complex type X that can IDREF to either complex type Y or complex type...

Google App Engine - DELETE JPQL Query and Cascading

I noticed that the children of PersistentUser are not deleted when using the JPQL query below. However, the children are deleted if I perform an entityManager.remove(object). Is this expected? Why doesn't the JPQL query below also perform a cascaded delete? @OneToMany(mappedBy = "persistentUser", cascade = CascadeType.ALL) private Colle...

How to store currently logged on user in DB?

Using Seam 2.1.2 and JSF 1.2 I wonder how to store the users login name in the database. In plain JSF I would simply lookup FacesContext.getCurrentInstance().getExternalContext().getRemoteUser();in a backing bean and set the value into a persistent object. How can I achieve that the users name will be stored in the DB? ...