hibernate

How can I use *.hbm.xml files as input in hbmtemplate for Maven?

In the Ant task of the Hibernate Tool hbmtemplate, it is possible to use *.hbm.xml files as input instead of reading table descriptions over JDBC. Is there a way to do the same in the hbmtemplate goal of the Hibernate3 Maven plugin from codehaus? In Ant, I can do this by adding a fileset to the configuration: <configuration configur...

Modelling a temporal-style relational table in Hibernate

Hi all, I'm trying to wrap Hibernate around an existing data model, which as expected has its ups and downs. My current sticking point is that one of the entity tables has a quasi-temporal model; no rows are ever deleted or updated; instead, the "is_current" column is set to false (and a new row is created with the new fields on an upd...

Many-to-many on the same table with additional columns

I have a class User. A user can be a friend with many other users. The relationship is mutual. If A is a friend of B then B is a friend of A. Also I want every relation to store additional data - for example the date when two users became friends. So this is a many-to-many relationship on the same table with additional columns. I know th...

Finding a hard time with Hibernate Code Generator Tool.. pls help

Hi All, I am trying to develop a wicket based web application using hibernate at the model layer with postgres DB. I created all my tables manually and i am trying to reverse engineer the code from the tables using hibernate code generator tool downloaded from www.hibernate.org. I have created the hibernate.cfg.xml and hibernate.reven...

Lingering Hibernate sessions without transaction in JBoss

I have encountered a Hibernate issue I just can't find my way around. We're running Hibernate 3.2.6 on JBoss 4.2.0, in a Spring 2.5.4 application behind JBossWS 2.0.1 (just to get all the version on the table). Normally this works just fine, but sometime the system spontaneously (i.e. for some reason currently not know to us) enters a s...

Guice, bind different database provider based on yaml config

I have an application config file that looks something like this: database: type: [db-type] username: [name] password: [pw] server: [ip] database: [db-name] db-type can be any of the following: {postgresql, mysql, mssql, file}. I wanted to configure the binding, such that (it's hibernate based) the app loads a special Provid...

Generating simple crud applications in Spring based off existing database or hibernate configurations?

I'm attempting to learn Spring MVC but have been spoiled by Grails. While I am able to get a basic web application working I was wondering if there were any tools that could do some of the work to create a crud application given a database or hibernate data model? The only one I've found so far is http://www.skywayperspectives.org/portal...

autocommit and @Transactional and Cascading with spring, jpa and hibernate

Hi, what I would like to accomplish is the following: have autocommit enabled so per default all queries get commited if there is a @Transactional on a method, it overrides the autocommit and encloses all queries into a single transaction, thus overriding the autocommit if there is a @Transactional method that calls other @Transaction...

Workarounds for unresolved hibernate bug when embedded collections contain collections?

When using hibernate, I get a ConcurrentModificationException when I have an entity A that contains an embedded collection of B, where each element of B contains a collection of Strings. In other words, A is an entity class and B is an embeddable class. A has a collection of B. Each B has it's own collection of Strings. This appears ...

cannot do 2nd level cache

in my applicationcontext.xml <bean id="annotatedsessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="packagesToScan" value="testonly.package.model" /> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect...

hibernate cache strategy

how to decide whitch CacheConcurrencyStrategy to use? NonstrictReadWriteCache, ReadOnlyCache, ReadWriteCache, TransactionalCache . I read https://www.hibernate.org/hib%5Fdocs/v3/api/org/hibernate/cache/CacheConcurrencyStrategy.html but doesn't explain in detail enough ...

config ehcache.xml for jpa entity or use annotation?

when using ehcache rather than defining statement like <cache name="testonly.package.model.TestPOJOcategory" maxElementsInMemory="200" eternal="true" overflowToDisk="false" timeToIdleSeconds="300" timeToLiveSeconds="600" /> can directly define inside entity independent of whatever cache pro...

Hibernate problems with Auto Increment ID MYSQL 5

So, I just stood up a Spring Hibernate app and I can't seem to get my mapping file right. I am using MySql 5 and an auto incrementing key. Here is the ID portion of my mapping file. <hibernate-mapping> <class name="org.XXXXXXX.Contact" table="contact"> <id name="id" column="id" type="int" unsaved-value="null"> <...

JPA @VERSION how to use it?

@Entity public class Person { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private Long id; private int salary; @Version private long version; // ...getters and setters } may i know is there required to create set/get for "version" ? in my code ,when persist (saveorupdate) this entity with hiber...

unique constraint check in JPA

I am enforcing a unique constraint check in JPA for userid column which is enforced for all records in the user table. @Table(name = "user", uniqueConstraints = @UniqueConstraint(columnNames = userid)) My requirement is that, the userid's within a particular organization needs to be unique and not across all organizations. How...

Tool for monitoring Hibernate cache usage

Is there any tool which would allow for monitoring Hibernate 2nd level cache usage? I know that I could use Hibernate API for retrieving such information. But what should I do when I have application which doesn't read the information itself, and I can't modify it? Is there any way to read cache statistics from the outside of the applica...

Web application with Hibernate, Spring and Oracle goes up to 99% of the CPU (row lock contentions).

Hi there. We have an web application in Linux environment that the CPU sometimes goes up to 99%. Sometimes it takes days, and other times it takes minutes. We are using Hibernate with Spring in a tomcat webapp and an Oracle Database. Checking the logs it appears the following: "ConnectionManager - transaction completed on session wit...

@UniqueConstraint check across multiple tables in JPA

Campus has @OneToMany Buildings Building has @OneToMany Rooms. Room names needs to be unique within a campus (e.g. campus-A, block-A, room-A and campus-B, block-A, room-A should be possible to store) Would it be possible to define such a unique constraint on the Room entity? ...

Using outer joins in HQL queries

I'm trying to build a query using HQL and OUTER JOINs and just can't get it work. Consider the following mapping <class name="Parent"> <id name="id" type="integer"> <generator class="native" /> </id> </class> <class name="Child"> <id name="id" type="integer"> <generator class="native" /> </id> <many-to...

java.lang.NoSuchMethodException: com.mchange.v2.c3p0.PoolBackedDataSource.setUserOverridesAsString(java.lang.String)

Hi all. I'm using C3P0 0.9.1.2 to configure data sources for my connection pool. When context is loading an error is raised. Here is the trace: java.lang.NoSuchMethodException: com.mchange.v2.c3p0.PoolBackedDataSource.setUserOverridesAsString(java.lang.String) at java.lang.Class.getMethod(Class.java:1605) at com.mchange.v2.c3p0...