jpa

how to simple add an object to a collection in hibernate from client

Hello, I'm trying to add an object to a collection in my client view and to save it on server with hibernate/jpa mechanism. Here is the problem: Take a Group object which can contains Account objects. On my client view (gwt), I create a new group (so the id is null) and I add to this group some accounts (where ids exist). BUT these ac...

Finding the current persistence unit for the current EntityManagerFactory

I noticed that calling createEntityManagerFactory(null) will use the default Persistence Unit (PU) in the configuration file. Sometimes the classpaths get really messed up at deployment and I'd really like to see the name of the current PU for a given EntityManagerFactory. Is there any way to do this? Also, I would love to go so far a...

Scalable Servlet Hosting

Possible Duplicate: What alternatives are there to Google App Engine? I would like to know if there is any alternative to Google App Engine. I have tried to use it with JPA, but it seems quite limited with the relationships and everything. Any kind of DBMS would do, as long as it's not too limited I found this post so I'm goin...

DB backup problem with Spring/Hibernate GenerationType.AUTO

Hi, I work with Spring/Hibernate Dao's for saving my Object in the Database. Now I had to backup all my DB inside my application. Now when I try to read my backup back, my application crashed. Now I found the problem for this crashing. It's Hibernate it creates automaticly a new ID for my Object when I want to save. For example I save...

How do I use a EJBQL between query with two identical dates?

I have a JPA named query that takes two dates in order to return records with a date column entry between the two dates. If I enter the same date for both the start and end dates it returns no rows, even though there are records for that date. Is there way to make the query work or shall I just run another query when the two dates are ...

When and why JPA entities should implement Serializable interface?

The question is in the title. Below I just described some of my thoughts and findings. When I had very simple domain model (3 tables without any relations) all my entities did NOT implement Serializable. But when domain model became more complex I got RuntimeException which said that one of my entities didn't implement Serializable. I...

ApplicationException - Java - Hibernate - rollback related

My question is related to Transactions and Exceptions Requirements: I have 10 records to insert into database table. And after inserting every record, I insert data into another table. So if inserting to second table fails, I want to rollback that record. Ex. Say handle cash transfer (from one account to account) for 10 persons at a t...

Adding Google App Engine support and keeping standalone support.

I have a java web application built on Stuts2/Google Guice/JPA. It uses hibernate as the JPA vendor. I would like to add support so it can be used on Google's App Engine. Of course I'm running into issues with the queries and mappings. Such as Many-to-Many and joins not being supported. I'm trying to come up with the best solution f...

Why is "public" not allowed for properties in JPA entities?

The JPA 2.0 specification says on page 22: The instance variables of a class must be private, protected, or package visibility independent of whether field access or property access is used. When property access is used, the property accessor methods must be public or protected. Why isn't public access allowed? ...

How to dynamically generate SQL query based on user’s selections?

This is the same question as: http://stackoverflow.com/questions/2040680/how-to-dynamically-generate-sql-query-based-on-users-selections The only difference is, that I'm interested in seeing solutions also using Java/JPA (+possibly EclipseLink or Hibernate specific extensions). I need to create a GUI, using which users can select seve...

AndroMDA maven code generation and JPA Annotations

I am using the AndroMDA plugin for maven to generate code from an uml diagram made in MagicDraw. When the code is generated, AndroMDA desings the JPA annotation for the persitence layer. I think that at the compilation process AndroMDA uses Naming Strategies to determine the Table and Column names for the DataBase. I want to determine ...

JPA @GeneratedValue on id

In JPA, I am using @GeneratedValue: /////////// @TableGenerator(name = "idGenerator", table = "generator", pkColumnName = "Indecator" , valueColumnName = "value", pkColumnValue = "man") @Entity @Table(name="Man") public class Man implements Serializable { @Id @GeneratedValue(strategy = GenerationType.TABLE, generator = "idGenerato...

Add Java Annotation to inherited field

I'm working on something that might benefit from a pattern like the following: public abstract class SomeBuisnessThingy() { protected int someDatapoint; } public class ADatabaseThingy() extends SomeBusinessThingy() { @SomeJPAAnnotation ???? someDatapoint; } public class AWebServiceThingy() extends SomeBusinessThingy() { @SomeS...

Reloading of persisted entity

I'm using OpenJPA in my application as a JPA vendor. The question is theoretical or conceptual: Is there any way to tell an entity manager to load an entity from the DB rather than from it's cache? The problematic scenario: EM1.persist(Entity1) EM2.merge(Entity1) EM1.find(Entity1) <--- Entity1 is the cached version rather than the m...

Support for schema migrations with JPA?

I've been briefly looking at JPA recently, and I was wondering what the deal is with database schema migrations and staying lined up with the classes you've created. Is there support in JPA for this stuff? Utilities? Best Practises? Cheers! ...

Wicket with Spring declarative transaction

It is possible to use the Spring Framework's @Transactional support outside of a Spring container. In reference documentation is chapter about AspectJ aspect. I'm trying to use it in my wicket application, but with no positive result. application-context.xml: <tx:annotation-driven transaction-manager="trans...

Criteria queries in JPA

Is there Hibernate criteria like queries in JPA? ...

oracle SUBSTR date duration

when i do query SUBSTR(e.updatetime - s.updatetime, 1,30) i will get result below +000000001 05:06:47.388000 can this save in java.util.Date? or which java class should i use other than String to ease me retrieve day,minutes,hours... p/s: e.updatetime is timestamp type ...

Dynamic order by in JPA/Hibernate?

The naive attempt query would look like this: Query query = em.createQuery("from org.domain.Resource r where r._parent = ? order by ?"); This does not work as the parameters should be data and not column names or syntax like ASC or DESC. What kind of workarounds you have figured out for this dynamic ordering? Concatenating the orderi...

Eclipse JPA project - defining connection to Oracle RAC

Recently I wanted to play a bit with Eclipse and JPA. Thus I wanted to create a JPA project. I got stuck when specifying the database connection, as editing the "Connection URL" (shown on the image) is not possible and I want to enter a (good, working) connection string to an Oracle RAC server which looks more or less like that: jdbc:...