Why would the following query fail due to a foreign key constraint? There is no other way for me to delete the associated data that I am aware of.
Query query=em.createQuery("DELETE FROM Person");
query.executeUpdate();
em.getTransaction().commit();
The I believe the offending relationship causing the problem is the activationKey fiel...
Hi,
I'm trying to decide whether to switch from having Hibernate sprinkled all over to using JPA2.0 and thus be provider portable.
1.Does JPA2.0 support custom user-types?
2.I'm on the verge of implementing Terracotta as a second-level cache to Hibernate with its clustering abilities mainly in mind. I would imagine, but I don't actually ...
I have a question about JPA-2.0 (provider is Hibernate) relationships and their corresponding management in Java. Let's assume i have a Department and an Employee entity:
@Entity
public class Department {
...
@OneToMany(mappedBy = "department")
private Set<Employee> employees = new HashSet<Employee>();
...
}
@Entity
public clas...
I am using JPA with hibernate and trying to connect to the a datasource to retrive information but when i run the application i get no error as such but no results are displayed when i run the following code.The question arose from a previous post located here when I was setting up the environment to do some testing of JPA with hibernate...
Is there any way that Criteria for qureies can be built on a remote (Swing/SWT etc) client? We've been using the DetachedCriteria functionality in Hibernate for quite some time, but would like to use standard JPA 2.
If not, could the code from hibernate be re-factored to create the remote API? Or is this something that might come alon...
Does JPA 2 have any mechanism for running recursive queries?
Here's my situation: I have an entity E, which contains an integer field x. It also may have children of type E, mapped via @OneToMany. What I'd like to do is find an E by primary key, and get its value of x, along with the x values of all its descendants. Is there any way to ...
Hello,
I have two entities User and Group:
@Entity
public class User implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private String username;
private String password;
private String email;
@ManyToMany
@JoinTable(name="user_group", joinColumns={@JoinColumn(name="USERNAME")}, inv...
Hello,
I have entities: Post, User, Comment with bidirectional relationships:
--------- 1 * ---------
| Post | <--------> |Comment|
--------- ---------
--------- 1 * ---------
| User | <--------> |Comment|
--------- ---------
I have simple page which displays single post and all its comments and...
Hi , I am trying to evaluate a mapping in this Hibernate document :
section 2.2.3.1. Generating the identifier property
http://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#entity-mapping-identifier
In the document , Person and MedicalHistory has @OneToOne mapping (MedicalHistory points to Person) , and the do...
Hi,
I'm trying to update my knowledge in Java, since I last used in when it was in 1.4.X version... I'm trying to use 1.6.0, in particular the Java Persistence API (2.0).
I managed to create an entity class. It's working, since I'm able to store and retrieve data.
But I was fooling around and when I decided to fill a JList with the co...
Typically , I use Hibernate's @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) to cache an @Entity class , and it works well.
In JPA2 , there's another @Cacheable annotation that seems to be the same functionality with Hibernate's @Cache. To make my entity class independent of hibernate's package , I want to give it a try....
Hello!
I have a problem with the architecture of JPA 2.0/ORM,
in our production system (and i believe in a lot of systems) we need the ability to change the SQL queries dynamically because slow queries and bugs in queries that was exposed only in production (heavy load and heavy data),
as a result we used in stored procedures and call t...
I have already seen
http://stackoverflow.com/questions/287201/how-to-persist-a-property-of-type-liststringin-jpa
and
http://stackoverflow.com/questions/796347/map-a-list-of-strings-with-jpa-hibernate-annotations
=============================================================================
I am trying to save
List<String>
throu...
I found some instructions how to configure pure hibernate to use EHCache. But I can't find any instructions how to configure JPA2.0 EntityManager to use cache. Hibernate 3.5.2 is my JPA2.0 provider.
edit//
Is @Cacheable(true) enough for entity? Or should I use @org.hibernate.annotations.Cache to configure the entity?
...
Guys,
maybe it's a silly question but I cannot find the answer in the docs:
How can set a limit to the CriteriaQuery using JPA2?
Thanks
...
Hi guys:
a little strange problem..
I'm doing a few testcases on an hibernate project:
when I call
EntityManager em = getEntityManager();
em.find(Foo.class, 1)
I get the entity as I expect, but when I invoke:
EntityManager em = getEntityManager();
em.find(Foo.class, 1, LockModeType.WRITE)
I'm getting null. Also, w...
Hi!,
I'm using Hibernate 3.5.5.Final and JPA2
How can make a testcase to test if the hibernate lock is working?
I wrote this, but seems that the test not pass in the current hibernate version (works fine in the previous version)
@Test(expected=OptimisticLockException.class)
public void testLock() {
EntityManager em = getEntityMa...
Since the programmer is forced to catch all checked exception, I to throw checked exception in case of any problem. I would like to rollback on any of those expections. Writing rollbackFor=Exception.classon every @Transactional annotation is very error-prone, so I would like to tell spring, that: "whenever I write @Transactional, I mean ...
@Entity
public class Person {
@ElementCollection
private List<Location> locations;
[...]
}
@Embeddable
public class Location {
private Integer dummy;
private Date creationDate;
[...]
}
Given the following structure, I'd like to perform the HQL or CriteriaQu...
@Entity
public class MUser implements Serializable, MemoEntity {
private static final long serialVersionUID = 1L;
@Id
private String email;
@OneToMany(cascade=CascadeType.ALL, orphanRemoval=true)
private Set<Meaning> mengs = new HashSet<Meaning>();
Shouldn't this mean that I get the constraint with a "on delete cascade"?
This is wha...