hibernate

In Hibernate, why Set is the recommended way to represent many-valued associations.

Taken from here: http://docs.jboss.org/hibernate/stable/core/reference/en/html/persistent-classes.html#persistent-classes-equalshashcode I tend to use List since Criteria returns List, so it makes my code cleaner since I don't have to do conversion. I do something like so.. @OneToMany(cascade= {CascadeType.PERSIST, CascadeType.REMOVE}...

Error in my hibernate request

Hello i have this HQL request and i have an error when I run it My function: public ProprietaireInt getProprietaireInt(String codeImmeuble, String annee) { //Create connexion Session session = getHibernateTemplate().getSessionFactory().getCurrentSession(); ProprietaireInt proprietaireInt = new ProprietaireInt(); try{ ...

Integrating JPA2.0 and Spring

Hello last few hours I try to test with spring jpa 2.0 3.0 Finally I could recover objects persisted but when I try to persist a new object I receive the following error message: org.springframework.dao.InvalidDataAccessApiUsageException: no transaction is in progress; nested exception is javax.persistence.TransactionRequiredExceptio...

Is it bad practice to use DiscriminatorFormula for migration of Hibernate databases?

I have an application using Hibernate for data persistence, with Spring on top (for good measure). Until recently, there was one persistent class in the application, A: @Entity public class A { @Id @Column(unique = true, nullable = false, updatable = false) @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; ...

Configure JDBC oracle specific property v$session.program using Jboss and JPA (hibernate)

I'd like to set the v$session.program Oracle property in order to have information available in the session table. I'm using JPA with a jndi XA datasource created with an oracle-xa-ds.xml deployed in the deploy folder of Jboss, and therefore I haven't access to the constructor of the Connection. I have access to the Connection object, in...

Hibernate Criteria API multiple joins

My hibernate entities are as follows: @Entity @Table(name = "EditLocks") public class EditLock extends AuditableEntity { /** The document that is checked out. */ @OneToOne @JoinColumn(name = "documentId", nullable = false) private Document document; Document then looks like this: public class Document extends Audit...

Hibernate joins every table in database

I've set up a small project as a test. I'm using BlazeDS and JPA with Hibernate on my test server, and flex with with dpHibernate to access the Java entities. Each Java entity extends BaseEntity, a class that contains ID and UUID fields. The Flex entities are created by DTO2FX. My problem is that, when I run the Flex project to try and ...

hibernate "IllegalArgumentException occurred calling getter"

Here's my class hierarchy (lombok generated constructors/getters/setters ommitted for brevity): public class A { ... other variables ... @OneToMany(fetch=FetchType.LAZY, cascade = {CascadeType.ALL}) private Set<B> bSet = new HashSet<B>(); } public class B { ... other variables ... @CollectionOfElements @IndexC...

Hibernate Parent/Child SELECT N+1 issue

Hi Folks (and Pascal), I jave the following mapped superclass that provides a basic implementation for a parent/child self relationship to create a parent/child list for unlimited nesting of items (i.e. Categories) @MappedSuperclass public abstract class ParentChildPathEntity<N extends ParentChild> implements MaterializedPath<N> { ...

Given a java object can I confirm its a bean persist-able by hibernate

there are times when I want to pass in an object to say an Auditing layer whose sole job is to persist the entities (no matter what type) , but since this is a public API, I want to ascertain that the passed in object is a hibernate entity bean and then only try the saveOrUpdate() ...

HibernateTemplate findByExample returns no results

I'm trying to use Hibernate QBE (actually, Spring's HibernateTemplate.findByExample() ) to return a list of users by their username. I use a "known good" value to search on (the username "JOHN.SMITH" does exist in the database). Unfortunately, I get no results back. Below is the unit test. @Test public void testQueryByExample() { ...

Map str_name from another table using my cd_label in NHibernate

I want to map an entity from database, but I can't figure out how do this using NHibernate. My entity "Module" have just three properties: id, name and a list of "Entities". But my database table have the columns: id, cd_entity, cd_label. So this is my problem. How can I map the property cd_label (that need join another table TB_LABE...

More than one relationship in two Hibernate Classes

Hibernate Gurus, I have a pesky issue and I don't really know how to solve my problem. I have a solution, however, I feel I may be reinventing the wheel. I have two entities, The first is a User Object, The second is an Alias Object. The relationship between the two is that A USER can have multiple ALIAS(es) and an ALIAS can be tied to...

Do I need Maven to use Hibernate?

I'm trying to use Hibernate for the first time, and early on in the getting started guide, it makes reference to Maven. If I'm not mistaken, Maven appears to be a build tool. However, I've been using Eclipse to build my project up to this point. Is there a way for me to use Hibernate without needing Maven? Can I just do what I need t...

Schema export with hibernate annotations

I'm using hibernate annotations and i want to export my database schema. Similar to the schemaexporttask with hbm xml files. ...

is it ok to mix session.save and various HQL updates that depend on that entity saving first

Hi, I've got a function with a session argument that does various HQL queries and HQL update statements in hibernate. They create sql that goes against alot of tables. All in one transaction. Now what I want to do is add one entity that this function depends on, in another function, with session.save, and then call the first function...

Abnormal behaviour by HQL while using JPA (*** More of an information to readers than a question *** )

Hello, I was trying to fire hql for some reporting purpose in my JPA based application. The following query that I tried kept conking out on startup (Since I had given it as a NamedQuery, it was checked for syntax at startup). Incorrect Query: SELECT t FROM Table_1 tb1 INNER JOIN Table_2 tb2 where tb1.name = 'someName'; After lot o...

Hibernate + EhCache = java.io.NotSerializableException

I'm doing load test now. After approximate 900 requests i got this error: [ 03.08.10 11:49:00.465] [Store org.hibernate.cache.StandardQueryCache Spool Thread] ERROR net.sf.ehcache.store.DiskStore - org.hibernate.cache.StandardQueryCacheCache: Failed to write element to disk 'sql: select hotelfeatu0_.name as col_0_0_ from feature hotelf...

Problem with rest web service?

I have a rest web service, that retrives data from my sql database using hibernate technology. While running, the web sevice throws error below java.lang.NoClassDefFoundError: Could not initialize class com.sample.restlet.HibernateSessionFactory com.sample.restlet.EmployeeResource.(EmployeeResource.java:22) sun.reflect.NativeCo...

How do I depend on hibernate annotated mappings from a separate project?

I am trying to work out how to do the mappings for two different projects that share some entities. Since they share only a limited subset of mappings, my first idea was to separate these mappings out into a separate jar. I'm using hibernate annotations to do the mappings (so they're in the class files, not separate XML). Both project A...