hibernate

what dependencies my project should have if I'm using JPA in Hibernate?

I use JPA, and Hibernate as its implementation. What maven2 dependencies I need to have in my project? ...

does it make sense to cascade "up" to owners in belongsTo relationship?

I have a Skill class, which hasMany RoleSkills. I have a RoleSkills class which belongsTo Role and Skill I have a Role class which hasMany RoleSkills For Role, I have a mapping that cascades operations to RoleSkills. The question is, does it make sense for RoleSkills to "cascade" back to Skill? I basically want to have a RoleSkill cr...

How do I get Hibernate to call my custom typedef?

I'm trying to define a CompositeUserType to handle a specific type in my JPA/Hibernate app. I have a CompositeUserType called ApplicationMessageType that is designed to handle my mapping. According to what I've read, I should be able to create a package-info.java class in my domain hierarchy that contains the TypeDefs. Mine looks like ...

Hibernate connection problems

I'm working on a webapp and I have connection errors after Hibernate throws exceptions : com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed. It gave me this exception each time I try to access my db after an exception occured. I now Hibernate's not supposed to throw er...

How to write a HQL query for Many To Many Associations?

I have 3 tables, Role[roleId, roleName], Token[tokenID, tokenName] & ROLETOKENASSOCIATION[roleId, tokenID]. The 3rd one was created automatically by hibernate. Now if i simply write a Query to get all the objects from Role class means, it gives the all role objects along with the associated tokenID & tokenName. I just wanted the associa...

Hibernate executed queries and testing

Is there a way to find out what queries are executed with hibernate? I would like to write a performance test to ensure only a specific query and amount are run. Update: Just a clarification, i would like to programatically find out how many queries are run, not just via visual-manual inspection, so it would easily testable. ...

Hibernate JoinColumn default name mssing '_id'

@ManyToOne(fetch = FetchType.LAZY) @JoinColumn (name = "account_id") private Account account; Works fine. @ManyToOne(fetch = FetchType.LAZY) @JoinColumn private Account account; Exception : Missing column account in SomeSchema.SomeOwnerTable * JPA Spec says default join column name is property name ( 'account') + '_' + target tabl...

How to Oracle XMLTYPE in Hibernate

One of the column is of the type XMLTYPE in Oracle database. In my application, I want to persist the data and using Hibernate. I did the following for mapping XMLTYPE in hibernate Define the custom user type implementing UserType The custom user type implementation is based on the blog link - http://community.jboss.org/wiki/MappingOr...

why my JPA annotated classes are not discovered implicitly?

My persistence.xml looks like: <persistence> <persistence-unit name="test"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <class>com.XXX.Abc</class> <properties> <property name="hibernate.archive.autodetection" value="true" /> .. </properties> </persistence-unit> <persistence> Everything w...

Using Spring defined transactionManager in JPA/Hibernate

Suppose you use JPA with Spring, with Hibernate as JPA implementation. JPA transaction mode is "JTA", so you need to pass the container transactionManager to Hibernate. The classical answer is to set hibernate.transaction.manager_lookup_class to the matching class for your server. However, I think it's a shame to have this depend of ser...

HQL: combine "insert into ... select" with fixed parameters values

I have HQL statement: insert into Item (ost, value, comments, startTime, endTime, proposedBy) select si.ost, si.value, si.comments, si.endTime, si.endTime, u from Item si, User u where si.ost = ? and u.id = ? How could it be modified to use parameters' values for ost and startTime columns while taking other columns from select? ...

Hibernate: Could not synchronize database state with session

While trying to insert a new entry to a Many TO Many associated table , i am getting this error: Could not synchronize database state with session I can understand that this is something deals with getSession() & session.close() But i cant able to figure it out exactly. For each transaction i am creating a new session. But i close all t...

JPA entity without id

I have database with next structure: CREATE TABLE entity ( id SERIAL, name VARCHAR(255), PRIMARY KEY (id) ); CREATE TABLE entity_property ( entity_id SERIAL, name VARCHAR(255), value TEXT ); When I try to create EntityProperty class @Entity @Table(name="entity_property") public class EntityProperty { pri...

Storing a hash as byte array with JPA

My User entity class contains password hash field, which is a byte array with a fixed length (32 since it's an SHA-256 hash). @Entity public class User { @Column(nullable=false) private byte[] passwordHash; ... } As you can see, I haven't annotated it with anything special, just a NOT NULL. This works, but will it perform...

Using JAXB to pass subclass instances as superclass

What I have is a set of Java classes (close to 25) representing message types. They all inherit from a Message class which I'd like to be abstract. Each message type adds a few additional fields to the set provided by the Message superclass. I'm implementing some RESTful web services using RESTeasy and would like to have methods like ...

Howto generate Hibernate POJO and mapping files dynamically

Hi Actually we are using custom table which will contain different columns for different clients so i want to generate Hibernate Mapping file and corresponding POJO at application deployment time. There are two solutions which i have already read on this forum are. using ant task in build.xml or using ant class file in my code for ge...

Spring ORM or Hibernate

Hi! I'm just wondering why the combination of Spring and Hibernate is so popular, when it would be possible to leave Hibernate out and use just Spring ORM? ...

upgrade to NHibernate 3.0.0.1002, Table is not mapped

Yesterday, I upgraded my NHibernate application from 1.2 to 3.0. I get the following exception c.SubContractors is not mapped [SELECT count(distinct c) FROM CallUp c, c.SubContractors sc Where sc.id = :id AND c.ChildCallUp IS NULL AND c.State > 0 AND (:start_date BETWEEN c.ContractStartDate AND c.ContractEndDate OR :end_date BETWEEN c.C...

Am I missing any important configuration?

Good afternoon, ladies and gentlemen, I have biult a web application using Hibernate for java. The application works fine on my local machine without SecurityManager, but when it is deployed on the remote server, the following exception is thrown: Sep 23, 2010 3:07:12 PM org.apache.catalina.core.StandardWrapperValve invoke INFO: java.s...

Struts2/Hibernate entitity update - null reference.

I have a Struts2 application that uses Hibernate/Spring. I have created an update form using s:select form elements - as in: Select form element is jsp - initialised correctly with current value: <s:select name="model.titleType.id" value="%{model.titleType.id}" list="#titleTypeSelect.titleTypeMap" /> Hibernate mapp...