I have two entities called User and UserProfile in my datamodel. Here is how they are mapped.
Code from User Entity:
@OneToOne(cascade=CascadeType.ALL)
@PrimaryKeyJoinColumn
public UserProfile getUserProfile(){
return this.userProfile;
}
public void setUserProfile(UserProfile userProfile){
this.userProfile=userProfile;
}
Cod...
Hello everyone,
I have an strange issue here.
I´ve got a JSF page which calls a webservice, in that call a Load entity is created. After that from the page I insert some Files, Load has a relation 1--> N with the files. After that I call the webservice to create a timer for making a few task with those services.
If I do that way JPA ...
A service tier that implements its persistence based on JPA can profit hugely from the second-level cache that is managed transparently by the JPA provider (e.g. Hibernate, Toplink/Toplink Essentials etc.). When this cache is activated, it holds instances of the persistent classes as soon as they were loaded from the database for the fir...
Is it possible to run a "MEMBER OF" query against associative arrays? If so, what does the syntax look like? The obvious workaround is a native query but that gets pretty messy what with all the joins and such. I'd like to test for existence of an object within the map's key set, value collection or entry set. Maybe something like th...
Is it possible to inject a persistence context into a scala actor every time it acts? I have a dual Java/Scala spring application, and I am using spring annotations to markup my Java services and methods as transactional. I'd like to use similar functionality within my scala actors. That is, the actor should operate within a single tr...
java.lang.ClassCastException: org.hibernate.type.SerializableType incompatible with org.hibernate.type.EntityType
at org.hibernate.id.ForeignGenerator.generate(ForeignGenerator.java:74)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:122)
at org.hibernate.event.def.Defau...
Let's say I have entities A, B, C and each A has many B and C entities. I want to query a load of A entities based on some criterea, and I know I will be accessing all B and C entities for each A I return.
Something like select a from A as a join fetch a.b join fetch a.c would seem to make sense at first, but this creates a huge product...
I have three entity classes A, B, C. A has a many-to-many relationship with B, and a one-to-many relationship with C.
select a from A join fetch a.b
Produces one query as expected
select a from A join fetch a.c
Produces n+1 queries.
What am I missing?
...
Whenever I try to set a list as a parameter for use in an IN expression I get an Illegal argument exception. Various posts on the internet seem to indicate that this is possible, but it's certainly not working for me. I'm using Glassfish V2.1 with Toplink.
Has anyone else been able to get this to work, if so how?
here's some example ...
What I am going to describe is a bit of legacy code. So there is a lot of stuff I cannot touch/change.
This pseudo-code runs well the in Jboss 4.0.3,
big_messy_sql = "select t1.f1 as somealias, t2.f2 as somehthingelse from obj1 t1, obj2 t2 where crazy_conditions....";
Query query = entityManager.createNativeQuery(big_messy_sql);
L...
I have code using JPA and everything works fine in my development environment and in unit tests. But deploying my modules into the OSGi target environment, I regularly run into the weirdest class loading issues. I really like OSGi, but if I can't fix this once and for all, I'm going to get stark raving mad. And as long as I don't underst...
I have a query:
select p from Product p
Which gives me the results I expect, but one of the columns (let's call it massiveDescription) is big, and since I'm querying the full list of products I want to exclude it.
I added @Basic(fetch=FetchType.LAZY) to getMassiveDescription() but this made no difference (the generated sql still incl...
Background
The application I am working on currently uses Spring + JPA. Everything was working fine before we decided to introduce DWR.
Using DWR I invoke a method on a Service class and it then redirects to the Controller.
try{
return WebContextFactory.get()
.forwardToString("/search.do?searchString=" + ...
I am able to create a simple JPA Java application from NetBeans using Apache Derby database. But when I try to do the same with SQL Server 2008, I keep getting the following error:
SEVERE: Application class sample.DBTestApp failed to launch
javax.persistence.PersistenceException: No Persistence provider for EntityManager named RS6910SQL...
I use MyEclipse to reverse engineer and make EJBs for me.
I make local interfaces and implementing facades.
How do I add/make new finder methods, do I just edit the generated interface and implementing classes?
I would rather not do this, for I may regenerate from time to time, then I would have to remember to add the new finders.
What ...
Because of some limitation, client asked that I can't use incremental "id" primary key, only compound primary key is allowed. And I can't use JPA annotation to have entity callback. Thus how can I know an entity is going to be inserted or updated ?
thanks a lot.
...
I have following Hibernate 3 mapping for User class:
<class name="org.test.User" table="users">
... some other mapping...
<map name="metadata" table="user_metadata">
<cache usage="transactional"/>
<key column="user_id" not-null="true" foreign-key="FK_USERMETADATA_USER_ID"/>
<map-key type="string" column="da...
So apparently we have the need to create persistence units on the fly. Basically we have this web service and a bunch of identical schemas with identical domain classes. We want to be able to pass a query to the web service where the context path matches a schema. The first time that the service is queried then pass in that schema name a...
Hello all,
I have a situation where I have a tree of Entities, and a Session Bean. The Session Bean simply persists or merges the entities, and the method in question is marked as @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW).
Now in the case that a child entity fails to be persisted/merged due to (for example) a foreig...
Can I use Criteria queries with EJB3 entities? If so, how can I combine them with EntityManager?
...