hibernate

FieldBridge for Timestamp in Hibernate Search

What is the FieldBridge for timestamp in HIbernate Search? @Field public java.sql.Timestamp approvedDate; ...

How to get a unique key for two fields with Hibernate?

I have two fields of an entity class which I don't want to be unique but to instead be used as composite fields for a key which must itself be unique. For example I have two fields (name and version) which can be the same for other records but together they must be unique. What is the best way to do that using Hibernate (with annotatio...

Hibernate is *NOT* throwing an exception (I think it should)

The Hibernate JavaDoc states that Session.update(Object o) would raise an exception if there's already a persistent instance of o, right? If there is a persistent instance with the same identifier, an exception is thrown. However, the following code doesn't throw anything when I run it. And I think it should! Email email = new Email("...

Is Hibernate worse than NHibernate?

How does Hibernate compare to NHibernate? I've heard the claim that "Hibernate is much worse than NHibernate, even to the point of not using it (and using JDBC over it)". Can anyone support or refute this? Update - I am not trying to decide between them. Our DAL team decided to use NHibernate for our .Net side, but not use Hibernate on...

Lucene BooleanQuery

How to use booleanQuery with StandardAnalyzer in Lucene Search? ...

Is it necessary to call a flush() (JPA interface) in this situation?

Hey fellows, Because calling a flush() to get every entities persist from memory to database. So if I use call too much unnecessary flush(), it could take much time therefore not a good choice for the performance. Here is a scenario that I don't know when to call a flush()? //Order and Item have Bidirectional Relationships Order ord = ...

how to write join query in hibernate

I have created two beans User and VirtualDomain with many to many relationship @Entity @Table(name = "tblUser") public class User implements Serializable { private Long id; private String username; private Set<VirtualDomain> virtualdomainset; @Id @Column(name = "id") @GeneratedValue(strategy = GenerationType.AUTO) public Lon...

How to return an entity with chosen columns using Criteria

I'm really new with Hibernate. I want a List<User> using hibernate criteria, but only with fields User id and name filled up. Is that possible? Something like the query shown below: SELECT user.id, user.name FROM user Regards. ...

Loading Type Entities in Hibernate

The setting is a typical MVC J2EE application, with DAOs for data access. There are a number of type entities, for instance for a Product bean there is a ProductType member bean, both persisted. When I am persisting a Product bean, I want to populate it with ProductType info. I have the status code, but do I have to go to the database ...

Order of Hibernate delete queries

Hello everybody Here is my data model (simplified) public class AddressBook { private List<Group> groups = new ArrayList<Group>(); private List<People> peoples = new ArrayList<People>(); @OneToMany(mappedBy = "addressbook", cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OnDelete(action = OnDeleteAction.CASCADE) @Cascade(org....

Hibernate mapping a second @Embeddable field in a subclass

I'm trying to map an @Embeddable object in a subclass whose parent class already has a field of that @Embeddable type. The hibernate Embeddable Objects documentation claims I can use the @AttributeOverrides to override the column names of an @Embeddable object: e.g. @Entity public class Person implements Serializable { // Persist...

JPA Many to Many cascade problem.

If I create a Customer and Controller, then associate my Controller with a customer it saves fine. If I then remove my controller it doesn't remove the relationship between them. This causes an EntityNotFoundException when I load the Customer. javax.persistence.EntityNotFoundException: Unable to find Controller with id 22 I'd like to...

where the heck is org.hibernate.tool.ant.HibernateToolTask?

Where the heck do I get org.hibernate.tool.ant.HibernateToolTask ? I can't seem to find a .jar file that contains it. ...

stumbling blocks galore while trying to run org.hibernate.tool.ant.EnversHibernateToolTask

I'm trying to run org.hibernate.tool.ant.EnversHibernateToolTask as suggested in the rather terse guide to Envers (2nd line of table, Documentation has a link to a PDF). Here's my ant task tweaked so it successfully finds org.hibernate.tool.ant.EnversHibernateToolTask and org.hibernate.tool.ant.HibernateToolTask; now it can't find org.ap...

JAR file gets modified during execution

This is after the last unsuccessful run of my program. I notice that the file size has changed and I can no longer run the Java class for my program: root@dbs01 ~ $ ls -l lifecycle-0.1-SNAPSHOT.jar -rw-r--r-- 1 root root 24740243 Jun 4 20:48 lifecycle-0.1-SNAPSHOT.jar This is after I copy the new copy of the original JAR f...

Can I have Hibernate create an object through factory method?

Is there a way to map a factory method in Hibernate (as opposed to having Hibernate call a default constructor and reflectively set properties or fields)? And if it can't be mapped, does Hibernate provide a hook for custom object creation on a class by class basis? Thanks! ...

Difference between JPA Entity and Hibernate Entity

When I annotate a class with @Entity and try to resolve the dependencies, I get to choose the package between two different packages, javax.persistence.Entity and org.hibernate.annotations.Entity The javax package is JPA's entity-annotation, but why is there a hibernate entity-annotation and difference does it have with JPA's annotation...

how to write delete query in hibernate for many to many relationship

I have two beans user and virtualdomain @Entity @Table(name = "tblUser") public class User implements Serializable { private Long id; private String username; private String deleteflag; private Set<VirtualDomain> virtualdomainset; @Id @Column(name = "id") @GeneratedValue(strategy = GenerationType.AUTO) public Long getId() ...

jboss hot deployment problems with hibernate

I have the following problem. When I deploy my ear file to server\default\deploy folder of JBOSS the first time, things seem to work fine. But then, with JBOSS still running, if I delete and recopy the ear file again, my unit tests fail with the exception listed below. It's like it loses the Hibernate mappings for the entities during th...

Java Persistence: Cast to something the result of Query.getResultList() ?

Hey everyone, I'm new to persistence / hibernate and I need your help. Here's the situation. I have a table that contains some stuff. Let's call them Persons. I'd like to get all the entries from the database that are in that table. I have a Person class that is a simple POJO with a property for each column in the table (name, age,..) ...