Hi,
I have one jar library A (or project in eclipse), which has it's own persistence unit (META-INF/persistence.xml) and some entity classes, and another project (B) using this one. In project B there is also persistence unit and entity classes.
In project B I need to use both entity classes from project A and B. But if I set "A" as pe...
What is the standard way to implement simple update?
Example: we have User with phone number NNNNNN and now we want to set it to YYYYYY.
@PersistenceContext
private EntityManager em;
public void update (User transientUser) {
what should be here?
}
User entity is as simple as possible:
@Entity
@Table (name = "USER")
public clas...
With Spring I can autowire a bean with the following property:
@PersistenceContext(unitName="foo") private EntityManager em;
Using the following I can manually autowire the bean "someBean":
ClassPathXmlApplicationContext ctx =
new ClassPathXmlApplicationContext("META-INF/applicationContext.xml");
AutowireCapableBeanFactory fac...
I have a JPA project connected to a MySQL database where my entity object is mapped to a table with a constraint on 2 columns. That is:
@Entity
@Table(name = "my_entity")
class MyEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id")
private Integer id;
@Bas...
I have been struggling with not being able to have the EntityManager be instantiated when I add a OneToMany column to a class that already has a OneToMany column.
Right now the EducationInfo has a OneToOne to user, since each row will be unique to a person, but I want to be able to load all the education information given a username.
I...
When using EntityManager, is it better to get one instance with PersistenceContext and pass it around in my program, or should I use dependency injection more than once?
In my application each client will communicate with a stateful session bean, and each bean needs to use EntityManager at some point.
I guess that bean methods are invoc...
Hi all,
I've got a pretty special setup: I create all the classes in Java, connect them in my application (several ManyToOne-relationships).
Then, I'd like to iterate over my objects and save them into the database. Sometimes, an object is already in the database, then it should not be persisted again.
I implemented the hashCode() and...
As of now I have a working Spring application with persistence. However now I want to use Hibernate with JPA to do all of my database activities. I want to do this using an entitymanager.
I've been reading many documents and tutorials on this matter, I've been getting confused on whether I need a persistence.xml file or not. Also I've ...
I'm getting this error from my EntityManager when I call the refresh function.
public void saveProduct(Product product) {
entityManager.refresh(product);
}
I heard this could be a bug with Spring/Hibernate, however I'm not sure how to get around this.
Edit:
the error is
java.lang.IllegalArgumentException: Entity not managed
or...
I'm new to JPA/OpenJPA and I noticed that if I don't call EntityManager.clear() after i persist entities I get an OutOfMemoryError (I keep adding new entities in a loop). I'm not sure if this is the expected behavior or it's just and OpenJPA 1.2.1 glitch.
So, am I required to explicitly detach the entities myself?
If I'm not, it's a go...
I am trying to attach a related persisted entity to a transient entity. This works fine in GlassFish V2 but not in GlassFish V3. This is a very simple scenario. Please look at the testcase at QueryException when reading Property of detached Entity
Many thanks.
...
Hi
I am new to Java EE. I tried to get some first examples running (JPA).
I am using Glassfish v3. The trouble is that I don't get the App Server injecting
the EntityManager. Hear is one example http://www.adam-bien.com/roller/abien/entry/ejb_3_persistence_jpa_for
which I extended with a JSP client.
Entity:
package beans;
import ...
I have my ear-project deployed in jboss 5.1GA.
From webapp i don't have problem, the lookup of my ejb3 work fine!
es:
ShoppingCart sc= (ShoppingCart)
(new InitialContext()).lookup("idelivery-ear-1.0/ShoppingCartBean/remote");
also the iniection of my EntityManager work fine!
@PersistenceContext
private EntityManager manager;
Fr...
Hi, I'm pretty much new to Spring & Hibernate. In our team, we are building a web application using Struts 2 for the presentation layer, with Spring 3 and Hibernate 3 (with Annotations) underneath. We are still debating on whether to use DAOs or not and Session's or EntityManager's for CRUD operations. Setting aside the question of which...
I'm following the guide here, but when the DAO executes, the EntityManager is null.
I've tried a number of fixes I found in the comments on the guide, on various forums, and here (including this), to no avail. No matter what I seem to do the EntityManager remains null.
Here are the relevant files, with packages etc changed to protect ...
I'm trying to deploy my application to a locally running GoogleAppEngine development server, but I'm getting the following stack trace when I start the server
Apr 23, 2010 9:03:33 PM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with na...
Hello,
I'm working on a maven project which uses seam 2.2.0, hibernate 3.5.0-CR-2 as JPA provider, DB2 as database server and Websphere 7 as application server. Now I'm facing de following problem:
In my EJBs that are seen also as SEAM components I want to use the EntityManager from EJB container (@PersistenceContext private EntityMan...
Hi.
What is essential difference between these methods?
query() of JdbcTemplate and createQuery() of EntityManager?
As I understand, both execute query?
...
My Flex application uses a client-side pimento EntityManager which fetches quite a few objects and associations. It does this by forcing eager fetching of particular association ends in the form of fetch plans. I would like to update the client whenever a change has been made to an entity existing in the EntityManager's cache. Is it poss...
I expect every instantiated entity to correspond to a tuple (& co) in the database. In the examples I see around, one always instantiates the entity (via a constructor) and then calls persist with that entity. I find this error-prone, and was wondering if it wasn't possible to have every instantiated entity automatically managed/persiste...