hibernate

Hibernate many-to-many mapping and cascade=delete

I have a mapping (only important parts): <class name="xyz.Role" table="ROLE" lazy="true"> <id name="id" type="java.lang.Integer"> <column name="ROLE_ID"/> <generator class="increment"/> </id> <set name="assignments" lazy="true" table="PERSON_ROLE" cascade="delete" inverse="true"> <key column="ROLE_ID" /> <many-to...

hibernate optimistic locking with lazy OneToOne associations

I've run into a variety of the 1-n selects problem described here (stack overflow). I have a Person object with a few OneToOne associations: Person { @Version public Long getOptLock(); @OneToOne(fetch=FetchType.LAZY) public PersonDetails getDetails(); @OneToOne(mappedBy = "person", fetch=FetchType.LAZY) public LoginFailure...

Help with foreign key mapping in Hibernate (Spring)?

I have the following two table (which are tied in with Spring security - but the issue I believe is with Hibernate): Table user Table authority The user table is tied (through Hibernate) to a domain object in my application: class User, which has the following attributes (and corresponding getters and setters), which correspond to col...

"Duplicate method" error when using Hibernate + Javassist + Gilead

My web app is using GWT 2.0.2, GXT 2.1.1, Hibernate 3.5-CR1, Javassist 3.11.0 and Gilead 1.3.1 (latest from SVN). My app was running just fine with GWT 1.7.1 + Gilead 1.2. I want to take advantage of some of the features of GWT 2.0, and figured I'd upgrade to the latest Gilead in the process. I pointed to the new gwt.xml file in Gil...

Spring transaction demarcation causes new Hibernate session despite use of OSIV

I'm using Hibernate with OpenSessionInViewInterceptor so that a single Hibernate session will be used for the entire HTTP request (or so I wish). The problem is that Spring-configured transaction boundaries are causing a new session to be created, so I'm running into the following problem (pseudocode): Start in method marked @Transacti...

How to handle simple mapping between two entities in ORM/Hibernate?

How best to use hibernate in a simple scenario (questions at end of the post) Lets say I have this Data Model in code: class UserGroup { int id; String name; } class User { int id; String userName; } For the User and UserGroup classes, the underyling database table will look exactly as defined by the classes above. Now, a ...

jpa pagination works very slow

I`m doing pagination, 2nd level cache is set up. Through hibernate+criteria it works fine, but through jpa it works much more slower. final String hql = "from Employee e " + "left join fetch e.positionedEmployees as p " + "left join fetch p.address as a " + "left join fetch p.comp...

How to prevent clash of "autonumber" field when exporting from one database to another?

Supposing I have a Person class that is persisted/loaded via hibernate: class { int PersonId; String Name; } PersonId is an "autonumber" that is generated by hibernate when saving the Person. Now lets say I made a bunch of Person's in a test database that I now want to copy over to the Production database.But, in Production database,...

GWT/Spring/Hibernate data change events and transactions

I'm working on an AJAX application using GWT, Spring and Hibernate. I'm keeping some configuration data on the client side, which is almost never changed, but when it is changed, I have to notify all clients about the changes via a data change event using GWTEventService. All of this is already working, but I noticed a problem concernin...

Hibernate: OutOfMemory when deleting with all-delete-orphan cascade option.

I have following mapping for my Category objects: @Entity public class Category extends CrawlableEntity implements Identifiable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Expose private Long id; @ManyToOne(fetch = FetchType.LAZY) private Category parent; @OneToMany(mappedBy = "parent", casc...

Override of an hibernate validator annotation ?

Hello, I would like to override a constraint in hibernate validator. Here is my base class: @Entity @Table(name = "Value") @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name = "valueType", discriminatorType = DiscriminatorType.STRING) public abstract class Value extends CommonTable { private String ...

Hibernate pluralization

I have A MySQL database currently in production use for a CakePHP application A Java SE application accessing the same database via Hibernate, currently in development. I'm using the Netbeans "automigrate" feature to create the POJO classes and XML files (do I really need the XML files when using annotations?). As the schema is quite...

cannot convert clob to string

I am trying to convert my clob object to string to display that on my JSTL page for that I am writting the following code public String convertClobToString(Clob clob){ String toRet=""; if(clob!=null) { try { long length=clob.length(); toRet=clob.getSubString(1, (int)length); ...

Nhibernate fires SQL commands

Hi all, when updating an entity A, NHibernate also send an SQL update command for some other entity B. A and B are not related. Just before saving entity A, the parent of entity B is loaded via a SQLQuery. Then, when accessed, B is lazy loaded (part of a collection). If I save entity A an update statement for entity B is generated as we...

Hibernate exceptionCould not parse configuration: .\WEB-INF\hibernate.cfg.xml

Hello All, I am getting the following exception when running my application in JBoss. ** Exceptions ** 2010-02-17 15:10:43,435 INFO [STDOUT] (main) ERROR [2010-10-17 03:10] [main] (HibernateUtil.java:22) - Hibernate exceptionCould not parse configuration: .\WEB-INF\hibernate.cfg.xml 2010-02-17 15:10:43,435 ERROR ...

Oracle 9i Session Disconnections

[Cross-Posting from ServerFault] I am in a development environment, and our test Oracle 9i server has been misbehaving for a few days now. What happens is that we have our JDBC connections disconnecting after a few successful connections. We got this box set up by our IT department and handed over to. It is 'our problem', so options li...

Prevent the same object from being associated to two different sessions in hibernate

Using jsf 1.2, hibernate, richfaces 3.3.0GA and facelets. I have this code in my backing bean: public List<Rater> getFreeRaters(){ GP myGP = (GP) user; update(myGP.getContract()); ArrayList<Rater> raters = new ArrayList<Rater>(myGP.getContract().getRaters()); ArrayList<Rater> selectedRaters = this.getSelectedRaters(); ...

How to run Spring Roo generated tests against a different database to Tomcat?

I have a collection of integration tests that have been generated by Spring Roo for my domain objects (and DAO ITDs). They appear to be fixed to use the "production" applicationContext.xml, which reads the database.properties and connects to the MySQL database schema I have set up for experimenting with the project: privileged aspect A...

recover Hibernate session state after a failed insert

The following code tries to insert an Item object to the db, using Spring+Hibernate. The Item has an Integer id field as primary key, as well as a name column which is subject to a unique constraint (simplified example). I know that the item's id is null (the item is transient) however the insert may still fail due to the unique constrai...

NHibernate - Unexpeted update wihout explicit update

Hi, after a child collection with one item in it gets lazy loaded when performing an SQL select on the parent, an update statement is executed for this child afterwards - without explicitly calling update. Parent mapping: <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="ParentEntity" assembly="ParentEntity"> ...