hibernate

Spring not finding Hibernate mappings file.

Hey guys, So I am taking Enunciate for a spin and have run into an issue when my servlet starts up. For some reason, despite the file being there, in the classpath, and everything being specified correctly, Spring tells me the following: 09-15@15:36:31 ERROR org.springframework.web.context.ContextLoader - Context initialization failed ...

Is this a ManyToMany JPA/Hibernate relationship or there is another way to map this ?

Hi, I'm getting started with JPA and created the following (simplified) tables; airport -------- id (pk) city code ... trip -------- id (pk) originAirport_id (fk) destinationAirport_id (fk) ... I'm trying to map this in JPA/Hibernate. In My trip object I created 2 airport objects: private Airport airportFrom; private Airport ai...

GORM Hibernate query

Hi, I have the following Grails domain objects class ProductType { String name static hasMany = [attributes: Attribute] } class Attribute { Boolean mandatory = false Integer seq static belongsTo = [productType: ProductType] } I would like to get all ProductTypes and their mandatory Attributes. Furthermore, I'd ...

A tool for converting database tables to entity java classes for hibernate

Hi; I need a tool for converting database tables to entity java files for hibernate. There are 20 tables (mysql) and I don't want to copy table's column name to my Java file and so on. Any suggestions ? Thanks. ...

Getting the correct Hibernate template in a generic Spring CRUD DAO

Hi, I'm still quite new to Spring, and I've found it to irritating making all these CRUD DAOs, so I've made a "public class GenericCRUDDAO extends HibernateDaoSupport implements CRUDDAO". In my service objects I then simply say something like private GenericCRUDDAO<User, Integer> userDAO = new GenericCRUDDAO<User, Integer>(); and no m...

Hibernate mapping error

I have created an .hbm.xml file : <xml version="1.0"?> <hibernate-mapping package="com.cmp.iard.sinistre.hbm.dossier"> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd > <class name="Personne" table="NOYS_PERSONNE" > ...

Hibernate saveOrUpdate() nullPointerException thrown on every second update...

Hi, I am having a problem with some hibernate code. I am calling the saveOrUpdate() method and every second time I try to do an update I get a NullPointerException. First time it works, second time it doesn't, third time it does. This is happening on updates. I am not refreshing the page, republishing the server, nothing. Here is m...

java.lang.NullPointerException on Hibernate persistent class

I have a persistent class Approvisionnement in my .hbm.xml file : <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" > <hibernate-mapping package="com.afrikbrain.iard.srv.attestation"> <class name="Approvisionnemen...

How do you enable hibernate query cache on a session level only?

Good day, What if I have a query that gets called multiple times in a single thread, and I just want to cache that query (and its result) for that thread (or for that session since I'm using one session per thread), how can I do that ? Note: My 2nd level cache is turned on but it's used mostly for session.get(...). But I do not want to...

eager-loading queries with GORM/Hibernate

Hi, My Grails app has the following domain objects class ProductType { String name static hasMany = [attributes: Attribute] } class Attribute { String name static belongsTo = [productType: ProductType] } My DB has 7 ProductTypes and each of those has 3 Attributes. If I execute the query: def results = Product...

Nhibernate: one-to-many, based on multiple keys?

Lets assume I have two tables Table tA ID ID2 SomeColumns Table tB ID ID2 SomeOtherColumns I am looking to create a Object let's call it ObjectA (based on tA), that will have a one-to-many relationship to ObjectB (based on tB). In my example however, I need to use the combination of ID and ID2 as the foreign key....

hibernate createSQLQuery bulk insert

i try to execute these 3 statements, 1 and 2 success, but when reach 3 statement, i get error, is it because i trying to insert into same table during statement 2 and cause statement 3 fail? by the way, all 3 statement is inside one @spring transaction session.createSQLQuery(" select groupid from group_ where groupid = 888880005").exec...

How to populate web application with initial data

I am writing web application and am wondering what the recommended way is to populate initial data. This is JPA/Hibernate and Spring application and is built by maven. Up to now I've used script wich populate database with initial data, started by hand. Unit tests work with theirs own data, created in code before each test. My test clas...

Hibernate cascade delete not working

Hi, I am having an issue with a delete I am trying to do in Hibernate. Everytime I try to delete I get an issue due to child records existing so it cannot delete the parent. I want to delete children and the parent. Here is my parent mapping: <set name="communicationCountries" inverse="true" cascade="all,delete-orphan"> <key ...

Strings > 4000 to CLOB conversion using hibernate

Hi, i have a java class persisting a string (>4k) into a database table into a CLOB field. If the string is less than 4k then it works. I have the field annotated using @Lob and initially I was getting an exception due to batching not supported for streams so I made the batch size 0 in the Hibernate config which is giving the exception...

Wrong SQL for view object using Hibernate Annotations

I'm working on a hibernate entity mapping for a database view; when I do a criteria query against it, hibernate is generating bad SQL. Any help figuring out what the problem is with my mapping would be greatly appreciated! I have two mapped entities which I am trying to grab from a database view; the view has no other columns, just the ...

Table Not Found with Hibernate and HSQLDB

Hey Guys We're using hibernate entitymanager to map our entities through JPA. And we are using HSQLDB in-memory database for unit testing. Everything was fine until a recent refactor to the model started causing the following error: 17:55:48.516 [main] WARN o.h.util.JDBCExceptionReporter - SQL Error: -22, SQLState: S0002 17:55:48.517 ...

JBossCache as a second level cache for Hibernate in JBoss 5

Here is my configuration: Hibernate 3.3.1.GA, JBoss 5.1.0.GA, JBoss Cache 3.2.0.GA. I'm doing Hibernate configuration as described here: http://www.jboss.org/community/wiki/ClusteredJPAHibernateSecondLevelCachinginJBossAS5 <hibernate-configuration> <session-factory> <property name="cache.use_second_level_cache">true</pro...

Hibernate template close transaction

I have next working code: Session session = null; try { SessionFactory sessionFactory = new Configuration().configure() .buildSessionFactory(); session = sessionFactory.openSession(); String id = (String) FacesContext.getCurrentInstance() .getExternalContext().getRequestParameterMap().get( "storeId"); Transac...

Making a OneToOne-relation lazy

In this application we are developing, we noticed that a view was particularly slow. I profiled the view and noticed that there was one query executed by hibernate which took 10 seconds even if there only were two object in the database to fetch. All OneToMany and ManyToMany relations were lazy so that wasn't the problem. When inspecting...