hibernate

how to check in hibernate primary key id used as foreign key in any table?

Is there any way to identify whther the particular primary id is stored in other table as foreign id?I have list of id's to delete. i have to verify whether these id's are used or not by refering its all child tables. is there any way to find it easyly? ...

Hibernate transform instance to subclass

Hi, I have mapped class in JPA. : @Entity @Inheritance(strategy = InheritanceType.JOINED) public class User { private Long id; private Long name; //getters and setters go here .... } I also have a subclass of this class, called Admin: @Entity public class Admin extends User { private String cridentials; //gett...

Hibernate, single table inheritance and using field from superclass as discriminator column

I have following kinds of classes for hibernate entity hierarchy. I am trying to have two concrete sub classes Sub1Class and Sub2Class. They are separated by a discriminator column (field) that is defined in MappedSuperClass. There is a abstract entity class EntitySuperClass which is referenced by other entities. The other entities shoul...

Why I need to explicitely save after a find with Hibernate?

Why I need the line "session.save(user);" in the following code snippet? I thought, with the find call the user is already attached to the session and changes will be tracked and commited. Would you mind to explain the details for me? Or do I need a special configuration or other circumstances where I could have heard about this 'feature...

how to pass cursor as IN parameter to a stored procedure

Hi, I want to pass a cursor to a stored procedure as IN parameter from my xyz.java file. I am using spring and hibernate. Can you help me with this. Needed urgently.Reply soon. And if cannot pass then can you help with some alernative. Thankyou. ...

A sample application in GWT + Spring + Hibernate

Hi, I've been thinking of using Spring + Hibernate with GWT, read a quite a few links on this topic but I'm not able to get started. So I'm looking for a sample application using GWT + Spring + Hibernate (at least Spring + GWT), could you please suggest any useful links !! Regards ...

Hibernate / JPA: duplicates in child collection

My data model is made of Schools and Students. Students have a FK to the School they belong to. I do not understand why the collection contains duplicates, i.e. Joe, Joe, Mary, Mary, Tom, Tom, etc The SQL query generated by Hibernate is correct and does not return duplicates. I could implement a hack to filter out duplicates, but I am no...

Hibernate or Grails - Need help understanding cascade

Hi, I am a college student who do not have a lot of experience on Hibernate or Grails. The main question that I have is mainly about where does cascading apply, does it apply only to attributes where there is an database entry for it or other wise? so for example If I have 2 Domains A and B... where B has hastable that is filled with A...

Hibernate Envers - traversing the relations

In my application, I have a several audited entity classes for example the following. It contains multiple HAS-IS relations to other entities with various hibernate annotations. @Entity @Audited public class Entity implements Serializable { private static final long serialVersionUID = 1L; @Id private Integer Id; @Man...

question regarding mulitple entityManagerFactory in Spring 2.5.6

I am using Spring+JPA+Hibernate in my application. The issue I am facing is that I have multiple databases in my application and I have configured them correctly(I think) in the applicationContext.xml. Please refer to my applicationContext.xml below and tell me if: That's how I am supposed to configure the multiple databases If yes h...

how to make the criteria list returns 0 if nothing is added

How do you cause the criteria.list() to return 0 if nothing is "added" to the hibernate criteria? (The criteria returns all entries in the table.) ...

Is it possible for hibernate to create the database and database user?

I have an application that uses hibernate and JPA to handle the database. I know that hibernate can create the database tables for me, however, I've found that I must first create the database files and the database user account before hibernate can create the tables. Is there a way for hibernate to do create the database and user accoun...

Memory leak with paged JPA queries under JBoss AS 5.1

Hi, guys, I'm trying to integrate Hibernate Search into one of the projects I'm currently working on. The first step in such an endeavour is fairly simply - index all the existing entities with Hibernate Search(which uses Lucene under the hood). Many of the tables mapped to entities in the domain model contain a lot of records(> 1 milli...

How to use UUID as primary key for Hibernate Entity?

I am trying to use UUID in Hibernate. Have the following Entity base-class description (with @MappedSuperclass annotation): @Id @Column(name="id") private UUID id; public UUID getId() { return id; } For test, I am trying to read all entities of my class from database (database exists, records exist). My database is PostgreSQL 8...

Problem with parent/child relation with hibernate

I am facing a problem with parent child type relations. Hibernate docs say to add a "many-to-one" relation in child class to get value of foreign key from parent. But to make this relation work I have to add Invoice property in child class that introduce a circular inclusion of parent into child and breaks my serializer. Could somebody ...

Hibernate Criteria: inheritence: Get a list of only the root class entities.

Hi, Assume i have: @Inheritance(strategy = InheritanceType.JOINED) public class Child extends Parent{ } How can i do a selection of only the instances saved as a Parent, not as a Child. Thank you ...

Generating Hibernate composite key object from hbm file

(Parenthetical rant:) I'm a Hibernate beginner getting slightly frustrated by the overhead of a simple join that I could write in 15 seconds in SQL. (End rant) The situation is thus: I have 2 tables that both contain the same composite primary key - let's call the columns in both tables 'ID' and 'Version'. I need data about a particula...

Preventing infinite loop data retrieval with Hibernate

Hi everyone, I was wondering: Imagine a scenario where e.g. //POJO public class User { private String userName; private String name; private String surname; private List<Blog> blogList; //All getters and setters are found here and assume they're generated. } public class Blog { private String title; private S...

What is the correct usage of the Seam @Transational annotaion?

I'm a bit confused about the meaning of values used in the @Transactional annotation, specifically @TransactionPropagationType. Perhaps Gavin thought it would be obvious enough from the name of each enum type and decided not to document the actual meaning... Be that as it may I have no clue what any of the following actually mean: MANDAT...

Hibernate - Saving Entities - Update Table - Not based on Primary Key

Pseudo code to get to the point: @Entity Person { @Id Integer id; String SSN; String name; } Use case for repository, or service: personRepository.save(new Person(ssn:"123456", name:"jeff")): id is unique and autoincremented primary key SSN is unique and is the identifier of a person name is just a string and could be ...