hibernate

How to load a set of objects when Hibernate Lazy Fetchtype is used?

I have a Hibernate domain class (let's say PetOwner) with a one to many relationship with another class(Pets) [PetOwner (1)---------(*) Pet] Due to a drastic change required to improve the performance I had to change the fetchtype of the getPets() method in PetOwner class to be lazy. So the current mapping looks as follows @OneToMan...

NHibernate and adding new items with a composite collection to a child collection

I have three classes that pose a problem when trying to add a new child. They are: User { List attributesGroup> } AttributesGroup { attributesGroupId value } AttributesGroupId { attrName userId } The mapping is: <class name="AlternativeUserAttributes" table="`AlternativeUserAttributes`" lazy="true"...

Reporting for multi-tenant web app

We have a multi-tenant web-based Enterprise application using Hibernate over MySQL. We use Jasper Reports for any reports that our customers require, but now we also need to offer ad-hoc reporting so that Users can run their own queries. How have others accomplished this? I am thinking that I can either: Provide a full export in exce...

working with object with spring and hibernate

Hello people! hope everybody is cool.I've been trying to do something with spring-hibernate but it's still a failure.i'm very new to it.i need a little help.supposing a POJO class Users.i want to return an Users object by username.While i had no problem to return Users object by id by doing this return (Users) getHibernateTemplate()....

Annotations to a grails relationship?

Looking for a way to include a conditional reference attached to a relation between two objects, for example class Person { String firstName String lastName static hasMany = [ readyNow: Role, readyLater : Role, emergencyReplacement: Role] static belongsTo = Role static constraints = { } String toString() { return firstName + " " + l...

Hibernaqte exception :org.hibernate.exception.SQLGrammarException: could not execute query

I am getting the following error. Not getting clue why is it coming. Also i checked DB it looks fine. Hibernate: select customer0_.CustomerId as CustomerId0_, customer0_.CustomerAlia s as Customer2_0_ from FF_REFERENCE.dbo.Customer customer0_ where customer0_.CustomerId=? org.hibernate.exception.SQLGrammarException: could not execute q...

Changing the type of an entity preserving its ID

Hi, everybody. I am using hibernate as a persistence layer. There are 2 entities that live in the same table extending one superclass with single table inheritance strategy. @Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) public abstract class A { @Id @GeneratedValue protected Long id; // some common fiel...

JPA/Hibernate - Embedding an Attribute

I am having a trouble mapping an embedded attribute of a class. I have created some classes that are similar to what I am trying to do to illustrate. Basically, I have an @Embeddable class hierarchy that uses Inheritance. The top level class "Part Number" has only one attribute, and the extending classes add no attributes to the "Part...

Creating Object from Hibernate Mapping

If I have a mapping like this: <class name="Users" table="users"> <id column="id" name="id"> <generator class="native"/> </id> ... <set name="types" table="types" cascade="all"> <key column="user_id" /> <element column="type_name" type="string" /> </set> </class> How should the user object b...

one-to-many with criteria question

enter code hereI want to apply restrictions on the list of items, so only items from a given dates will be retrieved. Here are my mappings: <class name="MyClass" table="MyTable" mutable="false" > <cache usage="read-only"/> <id name="myId" column="myId" type="integer"/> <property name="myProp" type="...

specifying constraint name in hibernate mapping file

I am using Hibernate 3 with Oracle 10. Is there a way to specify in a Hibernate mapping file the constraint names (from foreign keys, unique constraints, etc) that will be created rather than the (not user-friendly) generated ones? ...

Generating Hibernate hbm xml files & entities classes from existing DB schema

Dear colleagues, How can I generate Hibernate hbm xml files & entities classes from existing DB schema? Sharon ...

Hibernate/JPA - Foreign Key Index in Object itself

I am currently working on 100+ Java Objects created by someone with no JPA/Hibernate experience into JPA Entities. Their Objects reference other objects based on a Foreign Key in the Class itself. All of the primary Keys are generated outside of the database. For Example (Just to Illustrate) Car @Entity @Table(name="CAR") public cla...

postgresql: Large Objects may not be used in auto-commit mode [CLOSED]

Hi, I'm working on a application which uses spring and hibernate. We are using postgresql as the database. When I try to insert a record into a table which has a OID column it is throwing the following error. org.hibernate.exception.GenericJDBCException: could not insert: [com.greytip.cougar.model.misc.MailAttachment] at org.hibernate...

What can be done with 'PermGen out of space' exception in Tomcat-Spring-Hibernate web application?

We have an web application that uses Spring-Hibernate to persist registered users data in Oracle database. The application works fine in development environment, but when we copy it int live environment with much more data, it failed. Initially the application starts normally, but after few actions 'PermGen out of space' exception occure...

datasource configuration in standalone app when using Hibernate

Hi, I am wondering, where do we store database config in standalone app.The client is connected to database directly (I know it's not a good idea, but I am not allowed to create a server or open new port for RMI) I certainly don't want user open up Hibernate config xml file and get all the details (database username & password etc). ...

How to map a set of enum type in Hibernate?

In hibernate, is it possible to define a mapping for a class to a set of enums? I've been able to find examples of how to define mappings of Sets and I've been able to find separate examples for how to map Enums, but I cannot figure out how to define a of Enums for a class. Could anyone please provide me with an example? This is ...

Hibernate Avoiding n+1 queries - second level associations

I have a main table T1 which has a one-to-many relation with table T2 which inturn has a one-to-one relation with table T3. When I try to fetch the data from all the tables in my query using LEFT JOIN FETCH, I am getting "illegal attempt to dereference collection" for T2 which inturn is a collection set. I am have to get data from all ...

hibernate and Java.util.set problem

Hello good fellas! i 'm trying the hibernate tutorials from their main site and wanted to change thing a bit to know how many to many relationship work with java.util.set interface.My mappings are correct and i can insert in and from the tables EVENT, PERSON and the mapping table PERSON_EVENT.Now i've inserted some dummy values in the ...

hql error in select clause

When I am using HQL select clause following error is occuring .student is mysql table. Error: Hibernate: select studentcla0_.vStudentName as col_0_0_ from student studentcla0_ java.lang.String Below is Code: public static void querySubject(Session session) { String sql_query="select stud.strStudentName from StudentClass a...