I'm doing some werid reporting from JPA datastore.
I need to select (using EJBQL) list of objects and these objects contain collection of entities ie I have class that is constructed by:
FOOBean(String param1,
String param2,
List<Entity> listParam)
(notice that third parapeter is a list)
And I want to select list of thes...
I'm using Hibernate JPA and Spring in my project. Suppose if I try to insert a record with duplicate key value, the insert query will throw an exception.
Now, is it possible to get the table name, field name and possible cause for the exception from the SQL Exception object at run time !?
...
We are trying to dynamically generate an IN clause for a native sql query to return a JPA entity. Hibernate is our JPA provider. Our code looks something like this.
@NamedQuery(
name="fooQuery",
queryString="select f from Foo f where f.status in (?1)"
)
....
Query q = entityManager.createNamedQuery("fooQuery");
q.setParamete...
I'm in the processes of changing my DAO layer from using Hibernate API to using a pure JPA API implementation. It looks like the recommended method is to use the createNamedQuery from the entity manager. The named queries are stored in annotations in the model/entity classes. This just not makes sense to me. Why would you define the ...
I have a legacy schema that cannot be changed. I am using a base class for the common features and it contains an embedded object. There is a field that is normally mapped in the embedded object that needs to be in the persistence id for only one (of many) subclasses. I have made a new id class that includes it but then I get the error t...
The default mapping from an Oracle NUMBER value is into BigNumber... How can I get a scalar result query to return a Long instead?
...
Hi all. I'm curious and need to find this answer quick. Google won't help much.
The Java Persistece API has these properties that tell the framework to cascade operations on associated entities:
CascadeType.PERSIST
CascadeType.DELETE
CascadeType.MERGE
CascadeType.REFRESH
I know what the first two mean: when I persist object A which h...
What it says on the tin; I want to modify a collection in Hibernate without forcing the collection to load, since it is a large volume of data (~100,000 records, monotonically increasing).
Right now, I add an element to this list by calling getEvents ().add (newEvent) which, of course, causes events to be populated.
Here's the mapping...
I'm researching the development of Enterprise Applications in Java, .NET and Groovy. For each platform, we're going to try how hard it is to realize a simple SOAP web service. We'll use the tools and libraries that are most commonly used, to research the real world as accurately as possible.
In this regard, would it be best to use the n...
I am using NetBeans 6.7 Beta to create entity classes from a MySQL (version '5.0.45-log') database. NetBeans accepts most tables, but rejects certain ones consistently (I can't see a pattern), saying they have "no primary key". All tables are using the InnoDB engine. All tables have primary keys of one or more columns. The MySQL query br...
I get a java.lang.IllegalArgumentException: Unknown entity: path.to.MyEntity.
I have explicitly specified the provider in persistence.xml using:
<persistence-unit ...>
<provider>org.hibernate.ejb.HibernatePersistence</provider>
</persistence-unit>
and MyEntity is annotated appropriately.
The hibernate portions of the exception tr...
We have a postgres DB with postgres enums. We are starting to build JPA into our application. We also have Java enums which mirror the postgres enums. Now the big question is how to get JPA to understand Java enums on one side and postgres enums on the other? The Java side should be fairly easy but I'm not sure how to do the postgres sid...
I'm using EclipseLink with the "eclipselink.ddl-generation" property set to "create-tables". The order of the columns in the created tables seems random. I want the columns in a particular order - the order in which the fields appear in the Entity class definition.
Is there a way to tell EclipseLink to create the columns in the order ...
Using JPA query language, how do I determine the size (number of rows) in an entity (table)?
...
I have a @ManyToMany mapping where the table self-references through a mapping table, and we want to order on an order id in the actual mapping table, but are finding it difficult to configure this.
We could perform it in hibernate xml, so it is natural to assume the support is there in JPA annotations. Does anybody know how we can orde...
IDEs like Netbeans allow generation of entity classes through a persistence context. If you had access to underlying generation method (not sure if it is an external tool or part of the IDE), could you generate database entity classes dynamically at runtime? The idea being that you could hook into the entity classes using reflection.
I ...
Our application needs to use (read-only) a couple different persistence units pointing to different databases (different, commercial vendors as well).
We do not have the budget to enable 2pc on one of them (Sybase). Is there a way to use these in a transaction without it having to be an XA transaction?
We're using Websphere 6.1, Sybas...
I currently use JPA annotations only, but I really don't like that I'm polluting my entity classes with so many ORM details which really aren't relevant to their behavior (e.g. table name, id generation strategies, join columns...).
I see that DataNucleus recommends putting ORM-related annotations in XML instead (those colored in pink),...
I am trying to map a JPA (using Hibernate now) Many-to-one relationship with a polymorphic type, but I am having no luck. I don't see why it isn't possible, or why I would be forced to declare a concrete type in the mapping. Here is an example:
@MappedSuperclass
class BaseClass {
@Id
long id;
}
class ClassWithList extends Base...
I have 2 tables:
Movies:
movieID
Users:
userID
These tables have a many to many relationship through the Queue table, with
an additional attribute, listOrder:
Queue:
movieID,
userID,
listOrder
I'm attempting to model this using EclipseLink, but am getting an
"incompattible mapping" error. Here is a sampling of my code:
@...