hibernate

How do I delete a row in a join table automatically, to avoid a ConstraintViolationException?

This seems like it should be a pretty simple question, or at least have a simple answer. But - I'm really not a database guy, and I'm still pretty far down on the Hibernate learning curve. That said, here's the setup: Consider a unidirectional many-to-many relationship between two entities, from Foo to Bar: (pardon any typos below, th...

Hibernate - Perform HQL query on Criteria Result

Hi @ all, I am concerned with a problem regarding criteria and hql. In first step a complex criteria construction limits a big amount of datasets. In second step a hql calculation should be performed on these preselected datasets of step one. The problem is that the code of both has been developed seperately and i am wondering if it is...

Why has Hibernate switched to use LONG over CLOB?

It looks like that Hibernate started using LONG data type in version 3.5.5 (we upgraded from 3.2.7) instead of CLOB for the property of type="text". This is causing problems as LONG data type in Oracle is an old outdated data type (see http://www.orafaq.com/wiki/LONG) that shouldn’t be used, and tables can’t have more than one column ha...

Manage persistent context before flushing

hi, consider hibernate-link and JTA as peristence provider. How can I force em not to flush anything, and to handle it by myself? @Stateless public class SomeBean{ @PersistenceContext EntityManager em; public void method(){ em.persist(entity); // will get managed em.clear(); // everything gets unmanaged } } I would ex...

Hibernate Polymorphism (Extending Parent Class)

Question regarding Hibernate Polymorphism and extending a parent class (which I can not modify directly). My parent class is called Contact: @Entity @Table(name="contact") @Inheritance(strategy=InheritanceType.JOINED) public class Contact { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) public long id; public String name;...

<tx:annotation-driven /> leads to java.lang.ClassNotFoundException: org.aopalliance.aop.Advice

Anybody has an idea why adding the annotation-driven declaration leads to the aopalliance classes not found. I have not explicitly defined the weaving so using Spring defaults. Any help is appreciated ...

NHibernate creating a proxy instance failed due to abstract method

I'm new to NHibernate, and am trying to map a domain model that has a bit of inheritence etc (see this question for full details on my model, starting a new question as this is a different error) My base class has some abstract methods that each class beneath has to implement. This appears to be causing problems with NHibernate, even th...

Grails domain class query - how can I find by fields that link to another domain class?

Hello, Lets say I have two domain classes: class User { String name Role role } class Role { String name static belongsTo = [user: User] } and I create some records: def r1 = new Role(name: "role1").save() def r2 = new Role(name: "role2").save() new User(name: "user1", role: r1).save() new User(name: "user2", role: r2).save...

Hibernate: Risks associated with changing DiscriminatorValue

Given: @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name="postType", discriminatorType=DiscriminatorType.STRING) public class Post {} @DiscriminatorValue(value = PostType.BUG) public class BugReport extends Post {} That is ... Bugs start life in this system as a Post. Later, they can be promoted(?) to bei...

any hibernate program of multiple tables

Can i find any example of Java Hibernate in which have delete the data from multiple tables. ...

Hibernate: fetching a set of objects in an entity mapping

Hi guys, I've got an entity Case that has an id CaseId (unfortunately a string due to compability with a legacy system). This id is foreign key in the table Document, and each Case can have many documents (onetomany). I've put the following in my Case entity: @Id @Column(name = "CaseId", length = 20, nullable = false) private String ca...

any sample for batch processing in hibernate ?

Can i find the example of batch processing in java hibernate so that i can run delete queries on two tables. ...

cannot insert null in one to many relatioship hibernate annotation

I have a class A{Set b .....} which holds references of class B as Set. It is one to many relationship. Both class have sequencer in oracle. I put cascade to all in hibernate annotations. When i save class A, it gives me error that cannot insert null B.a_id . A-id is not nullable in my database. How can i persist this relatioship. ...

How to reference a map name for a subquery in an HQL order by clause

I've got an HQL statement like this: select new map (f1 as field1, (select ...) as field2) from ... where ... order by field2; It fails saying "Unknown column 'field2'". I experienced this in general that when using the "new map" statement, I can't reference the map names in the order by field. As HQL subqueries are only allowed in t...

Hibernate hbm2ddl ant file paths

Hello, I am having troubles with generating database schema with Hibernate Tools. This is my ant file <project name="Schema generator for MySQL database" basedir="."> <description> This file is used for running Hibernate Tools Ant task. It is used to generate database schema based on hibernate configuration </description> ...

Alternative solutions for Hibernate.Envers

Hi, i'm planning a historization for my java webapp (spring, hibernate). By googling I found Hibernate.Envers, which seems to be the perfect solution for me. Are there any comparable solutions? Thanks a lot! Jean ...

How to create indexes on multiple columns

We have the following entity relationships where a User belongs to a particular Organization. My queries either look like "select * from User where org=:org" or "select * from User where org=:org and type=:type" I have separate indexes on the User class. The first query will be fine, because of the Index on the foreign key element. Does...

Problem with SQL Connection

Hi all, I am working on a project which uses Java,Spring and Hibernate. I just came across a situaition like this. bean 1 : <bean id="cat" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="proxyInterfaces"> <list> <value>cat</value> </list> </property> ...

insert sql consumes long time in Hibernate

In my application I have two table, Group and Role, that are related between them with a @ManyToMany relationsheep. Since each Group can have many Roles and each Role can have many Groups. The first one: @Table(name = "groups") @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class Groups { private Set<Role> ro...

Hibernate Inheritance Modeling

Hi All, I'm having trouble creating a model for a couple entities that is sane in both Hibernate and the Database. Any help is appreciated. A company entity and table exists, which provides both a company name and a "company code". The company code must be unique. Company's may act as 2 different entities, clients or partners. We'd ...