Hi guys,
I've got an entity Case that has an id CaseId (unfortunately a string due to compability with a legacy system). This id is foreign key in the table Document, and each Case can have many documents (onetomany). I've put the following in my Case entity:
@Id
@Column(name = "CaseId", length = 20, nullable = false)
private String ca...
We have the following entity relationships where a User belongs to a particular Organization. My queries either look like "select * from User where org=:org" or "select * from User where org=:org and type=:type"
I have separate indexes on the User class. The first query will be fine, because of the Index on the foreign key element. Does...
hi
the find method does not return the latest version of an object.
somewhere in my code I find an object, change it, merge it and commit my changes. In the database the changes are made but in another function I find this object and my changes are not there.
I've checked race-conditions with the result that there are no race-conditions....
I thought I know how to JOIN in JPQL but apparently not. Can anyone help me?
select b.fname, b.lname from Users b JOIN Groups c where c.groupName = :groupName
This give me Exception
org.eclipse.persistence.exceptions.JPQLException
Exception Description: Syntax error parsing the query
Internal Exception: org.eclipse.persistence.intern...
I have two entity managers in my applicationContext.xml which corresponds to two different databases. I can easily query database1 with entityManager1, but when I try to access database2 with entityManager2, I am not getting any results. I am using Spring+Hibernate+JPA.
Here is my ApplicationContext.xml
<?xml version="1.0" encoding...
Today i have new problem with JPA/EJB3. I have 2 table User and Group
with mapping OneToMany (Group One - User Many)
When I use select statement in EJB, for example:
@NamedQuery(name = "Iuser.findAll", query = "SELECT i FROM Iuser i")
a conflict occur, it not know group field I choose where table? (group field in User Table is groupi...
Problem with OpenJPA. It returns null values on primary key. I debug the open jpa code and i can't find the reason why it returns null on the primary key. I start debugging and the openjpa finds the entry with all data an a value at the primary key but at some point in the code it changes the object and the primary key is gone
This is m...
In JPA, you can inject an EntityManager with the @PersistenceContext annotation:
@PersistenceContext
private EntityManager entityManager;
What is the JDO equivalent of this for a PersistenceManager?
@????
private PersistenceManager persistenceManager;
...
we are going to be working with an old database.
so it is very crucial that we do not modify the database/table/schemas under any circumstances (from the reporting modules), and as such i want to setup a persistence-context with some persistence units as read-only (for reporting modules), and some as normal JTA enabled.
we have already ...
Hi!
I'm using JPA over Hibernate in my web-app. Here are two entities (only getters are shown):
class Child {
private Parent parent;
@ManyToOne(optional=false)
@JoinColumn(name="parent_id", referencedColumnName="parent_id", nullable=false, updatable=false)
public Parent getParent() {
return parent;
}
}
class Parent {
...
I am new to JPA & Hibernate. After reading some online materials I now understand what Hibernate is and how it can be used with JPA.
Now, I am trying to run this JPA & Hibernate tutorial. I've done everything they mention in this tutorial.
I don't have Oracle DB, only MySQL. So I made some changes to persistence.xml using my understand...
I am trying to edit a table in Postgresql using JPA in Glassfish using EclipseLink. When I insert an entity, it runs fine. But, when I try to edit or remove the same entity, it fails with the following error. Any idea?
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistenc...
Hi,
For the last three days i am learning JPA by various examples, to change my JDBC code to JPA. Every JPA example and tutorial have main method to run it. Of course,
in main method only they defining EntityManager & EntityManagerFactory.
I dont have main method in my web application's server side code. Is that a problem in point of ...
@Entity
public class Person {
@ElementCollection
@CollectionTable(name = "PERSON_LOCATIONS", joinColumns = @JoinColumn(name = "PERSON_ID"))
private List<Location> locations;
[...]
}
@Embeddable
public class Location {
[...]
}
Given the following class structure, when I try to add a new location to the list of ...
@Path(value = "/user")
@Stateless
public class UserService {
@Inject
private UserManager manager;
@Path(value = "/create")
@GET
@Produces(value = MediaType.TEXT_PLAIN)
public String doCreate(@QueryParam(value = "name") String name) {
manager.createUser(name);
return "OK";
}
}
here is the u...
I am new to JPA & hibernate. In my web-app i have changed my JDBC codes to JPA. While running the web-app i am getting a BIG list of errors. But from my knowledge in JPA and Hibernate, I think the two errors below represent most of my problem.
Unable to configure EntityManagerFactory
16047 [31149935@qtp-23671010-1] ERROR org.hiberna...
My problem is very similar to this one : Injecting fields via Spring into entities loaded by Hibernate
The difference is that , I am using JPA2 entities , not hibernate . While the underlayer is still hibernate (3.5.5).
My spring version is 3.0.4.
What's the corresponding eventListeners in JPA's world ?
Sample code from the original ...
I have created a basic set of classes with methods for doing accounting.
My Ledger class allows you to maintain a basic ledger which allows you to obtain the current balance, and to perform transactions on the ledger that adds a new LedgeEntry.
I have this generic ledger system working well.
Insider Ledger is my LedgerEntry collection...
My object model is given below and would like your inputs on the number of indexes to create for faster query responses (on h2, mysql). Assumptions and questions are given below the following model.
@Entity
@Table(name = "user")
public class User {
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true...
Hibernate provides a mechanism to define multi column indexes via the Table. Is there a way to specify this is an ORM agnostic fashion via JPA or JPA2 (e.g. using the javax.persistence.* APIs)
...