jpa

Constraints in google-app-engine?

Hello, is it possible to use Constraints in the google-app-engine? It seems not to work ... http://www.datanucleus.org/products/accessplatform%5F1%5F1/jpa/orm/constr... The properties codingSystem and code should be unique. Is there a workaround? @Entity @Table(uniqueConstraints={@UniqueConstraint(columnNames= {"codingSystem","code"})...

Creating a JPA Provider

Does anyone know how to create your own JPA provider? I was considering making a custom JPA provider that could interface with a SOAP webservice we use. However, I can't seem to find any document describing how to create your own JPA provider. Where should I start looking? ...

jpa how to create new entity with same id as parent entity (JOINED Inheritance)

Hi folks, my question is very similar to http://stackoverflow.com/questions/1118873/changing-the-type-of-an-entity-preserving-its-id, but instead i´m using InheritanceType.JOINED instead of Table_per_class. This means i don´t to change any table, just to create a new subclass, with the same id as the superclass. To summarize, I have a...

JPA reference refactoring

I refactor some classes from standard SQL to JPA/ORM usage. In most cases the Objects have a "real" reference but sometimes the references to other objects are only given by an unchecked database id reference (no foreign key, just simple a string with a reference to another table id). The code looks like: @Entity public final class my...

How to map inner object using Hibernate/JPA without xml/annotation?

We have an object, A, which contains another object, B. We have Hibernate calling a stored procedure to query the data and populate instances of A. We're using the @NamedNativeQuery annotation with teh resultClass property set to A.class. This works great except that the instances of B are loaded lazily, as if Hibernate can't figure o...

Mapping calculated properties with JPA

Hi, Is there a way to map a calculated property using JPA? Assuming I have an Invoice object with one or more InvoiceLineItems within it, I want to have a persistent calculated property on the Invoice class that gives me the total amount: class Invoice { ... @Column(name = "TOTAL_AMOUNT") public BigDecimal getTotalAmount(...

Query partial entities with JPA

I have a JPA entity similar to; public class Inventory { private String productname; private String manufacturer; private Float retailprice; private Integer unitssold; private String ourcomment; } In about 2 out of 5 queries I need the whole entity, but the rest of the time I am not interested in unitssold and ourcomment. It fee...

Persist collection fields with hibernate

Using hibernate, how can I persist a class with a List<String> field? Consider the following entity class: @Entity public class Blog { private Long id; private List<String> list; @Id @GeneratedValue public Long getId() { return id; } public void setId(Long id) { this.id = id; } public List<String> getList(...

Removing an entity, but using the same primary key to add a similar entity after the removal

Im trying to remove an entity which has a unique PK like : 80253 I remove this entity by doing the follow lines of code: myEntityType1 = getEntityManager().find(MyEntityType1.class, 80253); getEntityManager().remove(myEntityType1); getEntityManager().flush(); These bits of code actually deletes the rows from my database and all its ...

Portable JPA Batch / Bulk Insert

Hi, I just jumped on a feature written by someone else that seems slightly inefficient, but my knowledge of JPA isn't that good to find a portable solution that's not Hibernate specific. In a nutshell the Dao method called within a loop to insert each one of the new entities does a "entityManager.merge(object);". Isnt' there a way de...

What are the various options and their tradeoffs for storing a UUID in a MYSQL table?

I'm planning on using client provided UUID's as the primary key in several tables in a MySQL Database. I've come across various mechanisms for storing UUID's in a MySQL database but nothing that compares them against each other. These include storage as: BINARY(16) CHAR(16) CHAR(36) VARCHAR(36) 2 x BIGINT Are there any better option...

MergingPersistenceUnitManager

I have recently found your reply in a topic about using multiple persistence.xml files from multi module project. You said something about MergingPersistenceUnitManager. Could you please tell me where can I find it ? The link you provided seems not to work. ...

When I persist, the entity doesn't show up in the list view.

I'm trying to add a new entity and then after a successful commit, redirect them to the list action. Here's a summary of what I'm doing: @Name("offerAction") @Scope(ScopeType.CONVERSATION) public class OfferAction implements Serializable { @In private EntityManager entityManager; private List<OfferSite> offerSites; @Factory("off...

Table not created by Hibernate

I annotated a bunch of POJO's so JPA can use them to create tables in Hibernate. It appears that all of the tables are created except one very central table called "Revision". The Revision class has an @Entity(name="RevisionT") annotation so it will be renamed to RevisionT so there is not a conflict with any reserved words in MySQL (th...

How to setup one-to-many unidirectional mapping for grails application on GAE ?

I try to perform testing on one-to-many unidirectional mapping for grails application on google app engine (GAE) using JPA. The one-to-many unidirectional mapping I attempt to define is between User and Role class. Unfortunately, I am stuck. Just curious is there any developer out there able to make it work successfully. Following is my...

JPA Definition of a One-To-Many Relationship with Junction Table

I have a one-to-many relationship modeled using an extra table: create table t1 (id int primary key, name varchar(10) /*...*/); create table t2 (id int primary key, name varchar(10) /*...*/); create table t1_t2 (t1_id int, t2_id int, primary key (t1, t2)); The tables are supposed to model the relationship of one t1 to many t2. What is...

JPA Instrumentation

Is it somehow possible to see the DDL produced when opening a EntityManagerFactory in JPA? I seem to be having some problems but no errors are produced. I don't see any sort of log file and no output is written to StdOut or StdErr. I have a log4j.properties in src/main/resources: log4j.appender.stdout=org.apache.log4j.ConsoleAppende...

Java Persistence / JPA: @Column vs @Basic

What is the difference between @Column and @Basic annotations in JPA? Can they be used together? Should they be used together? Or does one of them suffice? ...

What is the preferred design pattern for combining JPA,EJB and JSF managed beans?

Hi This is a design pattern question. Here is the scenario: I am using EJB3.0 with JPA. For example lets say I have a user who can belong to groups. So in my User entity I have a method getGroups() which fetches the groups lazily. And I have a UserDao which is a stateless session bean which has a method User getUser(int uid) Now in my ...

Can a single EntityManager (Hibernate) participate in multiple concurrent transactions?

Hi! Is there a way one EntityManager can participate smoothely in multiple concurrent transactions? Well, not that concurrent. Something like: Start tx 1 Do stuff in tx 1 Start tx 2 Do stuff in tx 2 Commit tx 2 Join tx 1 back Do stuff in tx 1 Commit tx 1 with steps followed one by one not overlapping. ...