hibernate

Using Hibernate in netbeans web application

I tried to create very small web app in NetBean using hibernate .I placed hibernate3.jar , log4J-1.2.14.jar,sl4j.api.jar,sl4j-log4ja2-1.5.6.jar,dom4j-1.6.1.jar, jta.jar, ehcache.jar under " Libraries" folder. I also place hibernate.cfg.xml under "default "package of "source" folder and default log4j.properties file and Book.hbm.xml und...

using hibernate plugin in netbeans web application

Hi everyone ,I want to use hibernate plugin in web app in netbeansIDE. But my pc is not connected to internet. So pls tell me the steps how to use hibernate plug in for web application of netbeans IDE. I also want to know the links to download for required file. I am a beginner of studying web app so pls help me. ...

Using MS SQL/Oracle's XML datatype in Hibernate

Is this possible? Situation is that I want to store some XML in my database, but keep it as generic as possible in case we need to deploy it to a difference backend. I realise I could store it as a String, but I believe MSSQL/Oracle optimise and validate XML if you store it this way, and let you search on it? ...

How can I create a ddl for my jpa entities from java code?

Hi, I look for a way how I can create a ddl for my jpa annotated entities. I prefer a pure java way for this. If possible it would be nice to have generate the drop statements too. ...

Hibernate Caching issue

Hi All, I am using hibernate to connect to the database. I am facing an issue which i think is regarding caching/flush. The situation : I am saving an entity e1 in the database and then i am adding e1 in another entity e2. when i try saving the e2 it is not able to find e1 and throws an index out of bound exception as i am loadi...

Getting the return value of a PL/SQL function via Hibernate

I have a PL/SQL function in an Oracle database that I can't change. This function takes a parameter which identifies an entity, creates a copy of that entity and then returns the ID of the copy. This looks something like FUNCTION copy_entity(id IN NUMBER) RETURN NUMBER I need to call this function from Hibernate. I tried creating a nam...

How can I access lazy-loaded fields after the session has closed, using hibernate?

consider this scenario: I have loaded a Parent entity through hibernate Parent contains a collection of Children which is large and lazy loaded The hibernate session is closed after this initial load while the user views the Parent data The user may choose to view the contents of the lazy Children collection I now wish to load that col...

queries in Hibernate polymorphism

I'm relatively new to Hibernate and am trying to migrate a relatively simple existing database to something that I can use with Hibernate, and am looking for advice on how to structure my application. I have 3 types of entities: Item Category PropertyType Item and Category and PropertyType are all similar; they both have a name, des...

How to query for map element in hibernate?

I have a hibernate mapping which looks like this: <hibernate-mapping> <class name="MutableEvent" table="events" mutable="true" dynamic-insert="true" dynamic-update="true"> <id name="id"> <generator class="assigned" /> </id> <property name="sourceTimestamp" /> <property name="entry...

Exposing Hibernate criteria via service API

This is more of a design than implementation question and it's going to be long so bear with me. It's best explained with an example: Let's say I have a business entity called Product with a bunch of properties (name, price, vendor, etc...). It's represented by an interface (Product) and implementation (ProductImpl, mapped in H...

Hibernate and JPA - Error Mapping Embedded class exposed through an interface

We have a set of interfaces, used as an API, and referenced from other modules. A set of concrete implementations of those interfaces, private to the "main" app module. These classes carry a number of annotations (JPA as well as XStream for XML serialization). I've run into a problem. We have a user class which had a number of fields w...

Hibernate Error: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session

I have two user Objects and while I try to save the object using sessio.save(userObj) I am getting the following error : Caused by: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.pojo.rtrequests.User#com.pojo.rtrequests.User@d079b40b] I am cre...

Password encryption with Spring/Hibernate - Jasypt or something else?

In a Java application stack with Spring & Hibernate (JPA) in the Data Access Layer, what are good methods of applying the password encryption (hopefully using annotations), and where can you find out more about getting it done (tutorial, etc)? It's understood that I would use a JCA supported algorithm for encrypting the passwords, but I...

MySQL enum with hibernate

I have a database table using an enum. This is already working with hibernate (using XML), and I'm trying to convert it to annotations as this is one of the last pieces to still be using xml notation. The column definition: enum('Active','Pending','Cancelled','Suspend') The following works: <property name="status" column="S...

pitfalls of collections of entities in Hibernate

OK, this is a follow-up question to this one, since I am really confused now. Suppose I have a one-to-many or many-to-many association between entities Person and Event such that a Person class in Java contains a Set<Event>. (Let's ignore whether Event contains a single Person or a Set<Person>.) Events are entities stored in a database...

JSF Hibernate decision support

Hi guys, I like JSF and Hibernate but I have a a problem to make the right decision: In fact, I have POJOs for Client, House, Problem and son on. and a Business delegate RentManager. and the programs might help the client to report one or more problems his/her house might have. I want to get all clients, houses, and problems. Can Rent...

Spring MVC Domain Object handling Best Practice

Lets assume a simple Spring MVC Controller that receives the ID of a domain object. The Controller should call a service that should do something with that domain object. Where do you "convert" the ID of the domain object into the domain object by loading it from the database? This should not be done by the Controller. So the service m...

Hibernate not fetching public member

Consider the following code: @Entity @Table(name = "a") public class A implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name="id") public int id; @Transient public B b; public B getB() { return B; } } When I fetch A, I'm manually filling B (another hib...

Hibernate configuration

I'm trying to get started with Hibernate, and when executing my program I get an error during initialization. The exception is thrown by this class, copied from here: package net.always_data.bastien_leonard; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; public class HibernateUtil { private static fi...

Hibernate getting on my nerve. Delete question on One To One relationship.

Hi all, I have these classes. @Entity @Table(name ="a") class A{ private Integer aId; private B b; @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id_a") public Integer getAId() { return aId; } @OneToOne(mappedBy = "a", cascade={CascadeType.ALL}) public B getB() { return b; } } @Entity @...