hibernate

Reverse engineer DDL from JPA entities

I'm playing around with some JPA stuff, changing the mappings to see how they're supposed to be etc. It's basic experimentation. However I can't find a tool that will simply read my entities and then generate the table schema for me. I tried to find something like this in JBoss tools but nada. Eclipse integration will be a huge plus but ...

JPA/Hibernate bulk inserts slow

I'm doing bulk inserts with JPA using Hibernate as my provider. The DB is Oracle. It created a sequence generator, and each time it does an insert it queries the sequence generator for nextval. If I'm doing 1K inserts, it will hit the sequence generator 1K times. Any way to speed this up, if I want to stick with JPA? ...

hibernate DAO design

do i have to open and close session and transcation in each function (make object ,delete object ,findbyID) can u give me a DAO implenetation for findall (lazy initialization ). ...

How can I extend Java code generated by JAXB, CXF or Hibernate tools?

With generated Java source code, like code generated with Hibernate tools code generated with JAXB schema binding (xjc) code generated with WDSL2Java (cxf) all generated classes are "value object" types, without business logic. And if I add methods to the generated source code, I will loose these methods if I repeat the source code g...

Hibernate: lazy-loading doesn't work on one-to-many mapping on set

Hi, I'm using Spring together with Hibernate for developing a Portlet for the Liferay portal server. I now have basically two entities, A and B, where A possibly contains many B's. So this goes to a one-to-many mapping between the two. <set cascade="all" lazy="true" name="comments" order-by="creationDate desc"> <key column="lfpn_pin...

Hibernate DAO

Can anyone suggest me a DAO implementation for a web application? What will be the problem if I create a transaction for fundamental operation (e.g. findByID(), findALL(), creatObject(), deleteObject(), etc.)? Please suggest me a DAO implementation that supports lazy operations. ...

hibernate lazy initilization problem

I want to manage a Transaction in my persistence layer, But when I try to fetch the results lazily I get this error: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role Can I use LockMode or any other way to solve this problem? Can a find a Object by its id without any Transaction? ...

Hibernate Queries

Using Named Queries (located in your hibernate mapping xml file) is a nice way to separate your queries from your buisness logic. But what are the alternatives if your are using Hibernate Annotations for mapping? ...

Hibernate - @ManyToMany with additional fields in mapping entity

Hi there. My simplified Entity Scenario is as follows: A PERSON is associated to a COMPANY in a specific ROLE (yawn). My first thought was to configure a ManyToMany relationship between PERSON and COMPANY. However and apparently, I can not include the type of ROLE in the ROLE table that way (as another field the two foreign keys). I ...

hibernate Open Session in View

i am using the following approach to sole lazy initialization problem in hibernate.Pleas tell me whether it will work or not . I have to implement my transcation in my persistance layer compulsary due to some reasons. public class CourseDAO { Session session = null; public CourseDAO() { this.session = this.session = Hi...

How can I configure hibernate to use context-specific connection information?

I'm writing a J2SE (Note, not JEE) application using Hibernate, and I need to provide a different connection to Hibernate for each thread of execution. These connections must be pooled, and each one has at the very least different authentication and, possibly, a different JDBC URL. The connections will be re-used (as can be inferred fr...

noob project to learn Spring/Hibernate

I want to get my feet wet with Spring/Hibernate. But I think I move along faster and am more motivated if I am working with code rather than just reading a book chapter by chapter. Does anyone have any good ideas for a home project to work on to learn these technologies? Any exercises that you might have worked on and thought useful? O...

hibernate lazy solution. Is it right?

i am using the following approach to solve lazy initialization problem in hibernate. Please tell me whether it will work or not . I have to implement my transcation in my persistance layer compulsary due to some reasons. public class CourseDAO { Session session = null; public CourseDAO() { session = HibernateUtil.getSe...

EHCache doesn't seem to work

Hello guys, I've set up ehcache on our Java application, which uses Spring and Hibernate. However, when I run Junit tests and print the stats, it seems there is nothing in cache: OUTPUT OF CACHE MANAGER STATS ON EVERY CACHE: COM.****.SERVICES.CLARITY.DOMAIN.ACTIONITEM.BYRESOURCEUNIQUENAME: getCacheHits: 0 getCacheMisses: 0 getObjectC...

hibernate hbm2hbmxml

I am trying to use ant hibernatetool task to generate hbm.xml files from my db schema in mysql. ant task runs without errors but no hbm.xml files are generated. What am I missing... Here are the relevant coonfigurations: build.xml <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="...

How to tune performance of hsqldb/hibernate app

I have an open source Java application that uses Hibernate and HSQLDB for persistence. In all my toy tests, things run fast and everything is good. I have a client who has been running the software for several months continuously and their database has grown significantly over that time, and performance has dropped gradually. It final...

JPA Hibernate One-to-One relationship

I have a one-to-one relationship but hibernatetool complains when generating the schema. Here's an example that shows the problem: @Entity public class Person { @Id public int id; @OneToOne public OtherInfo otherInfo; rest of attributes ... } Person has a one-to-one relationship with OtherInfo: @Entity public cl...

Get the entity previous version in Hibernate Envers

I have an entity loaded by Hibernate (via EntityManager) User u = em.load(User.class, id) This class is auditaded by Hibernate Envers. I want to load the previous version of this class. How can I do it? Thanks ...

How can I define multiple sessionfactory instances in Spring?

I would like to have multiple Hibernate SessionFactories in a spring application, all of them with identical configurations except for the DataSource. Ideally, I would acquire a particular SessionFactory by name. I need to be able to do this based on runtime state, and it isn't possible to determine which session factories I will need ...

Does an ORM integrate with existing applications or do I not understand?

Assume Hibernate for the ORM. I'm not sure how to ask this. I want to build an application that can replace part of another. For example, say I have an application with various modules, called the "big" app. This application may handle HR, financial, purchases, skill sets, etc. But maybe, for whatever reason, I don't like the skill ...