Category Archives: Hibernate

How to implement a self join in hibernate

Source : http://viralpatel.net/blogs/hibernate-self-join-annotations-one-to-many-mapping/ We have a create table in the database. CREATE TABLE employee (employee_id NUMBER(10) NOT NULL,firstname VARCHAR2(50) NULL DEFAULT NULL,lastname VARCHAR(50) NULL DEFAULT NULL,manager_id NUMBER(10) NULL DEFAULT NULL,PRIMARY KEY (’employee_id’),CONSTRAINT ‘FK_MANAGER’ FOREIGN KEY (‘manager_id’) REFERENCES ’employee’ (’employee_id’)); Here … Continue reading

Posted in Hibernate | Leave a comment

How to integrate Spring and Hibernate

Here are the few tips I have gathered on how to integrate spring and hibernate. Create your bean.xml something like this… Connection.properties ${db.driverClassName} ${db.url} ${db.username} ${db.password}com.usermanagement.pojo.Usercom.usermanagement.pojo.Rolecom.usermanagement.pojo.Privilegecom.usermanagement.pojo.Passwordcom.usermanagement.pojo.PasswordPolicy org.hibernate.dialect.Oracle10gDialectupdatetruetrue <!–org.hibernate.cache.SingletonEhCacheProvider–>org.hibernate.cache.EhCacheProvider The list of jars that you might need are antlr-2.7.6.jar asm-1.5.3.jar axis2-spring-1.6.1.jar … Continue reading

Posted in Hibernate, Spring | Leave a comment

duplicate import try, using auto-import="false"

How to use same entity class in two different packages in hibernate? Source : http://isolasoftware.it/2011/10/14/hibernate-and-jpa-error-duplicate-import-try-using-auto-importfalse/ Using Hibernate and JPA you cannot have two classes with the same name (on different packages) mapped. This raise an error at runtime:Caused by: org.hibernate.DuplicateMappingException: … Continue reading

Posted in Hibernate, Java | Leave a comment

How to upload file using struts and hiberate?

How to upload file using struts and hibernate? I spent 5-6 hours figuring out how can I upload a file into Blob in a database. So I decided to write a short article. Add enctype=”multipart/form-data” in the form tag (in … Continue reading

Posted in Hibernate, Struts | 2 Comments

insert doesn’t works on hibernate??

Source : http://www.coderanch.com/t/219259/ORM/java/insert-doesn-work-hibernate insert doesn’t work on hibernate Hi, Whenever I try to insert data through hibernate into DB, it displays all the steps executed but it doesn’t insert a new row into the database. Please tell me what could … Continue reading

Posted in Hibernate | Leave a comment

Column names in hbm.xml

When i added a field in my pojo class, with name xMoveCompatibleItem and I used eclipse’s inbuilt feature to generate getter and setter methods Eclipse generated methods with the following names:getXMoveCompatible()setXMoveCompatible(String) Note that X and M are both capital and … Continue reading

Posted in Hibernate | Leave a comment

Premature end of file when running junits

Problem: Premature end of file error when running Junits [junitreport] [Fatal Error] :-1:-1: Premature end of file.[junitreport] The file /tmp/repository/Yogesh/task2652_story1984/modulesmgr/junit_report/out/xml/TEST-com.coresecurity.ctrlsvc.modules.ModulesImportAndBasicCRUDTest.xml is not a valid XML document. It is possibly corrupted. Observations:1) TESTS-testsuites.xml was coming out to be empty.2) The resulting … Continue reading

Posted in Hibernate, JUnit | Leave a comment