How to use Set in Hibernate Example ?

How to use Set in Hibernate Example ?   Set is a collection which stores only unique values, if you like to store the duplicates then you can go with List. As we know creating a session factory is the mandatory basic one for any hibernate, creating a hibernate session factory now, package in.javadomain; import org.hibernate.HibernateException; import org.hibernate.SessionFactory; import org.hibernate.boot.registry.StandardServiceRegistryBuilder;

187 total views, no views today

» Read more

Difference between session and sessionfactory hibernate?

Difference between session and sessionfactory hibernate? Basically session will be created from the sessionfactory instances. I have listed down the few differences between the session and sessionfactory in hibernate. Sessionfactory: It is one instance per datasource/database. It is thread safe. It is a heavy weight object, because it maintains datasources, mappings, hibernate configuration information’s etc. Sessionfactory will create and manage

1,475 total views, 11 views today

» Read more

Java Program with Hibernate is not terminating

Java Program with Hibernate is not terminating: In hibernate you would have created the hibernate session factory to open the session and work with the databases. In that case you will face the program not termination issue sometimes. Rootcause: Once the program execution finishes session and sessionfactory should be closed, When it is not closed then you may face Java

235 total views, no views today

» Read more

How to set up Java Hibernate with MySQL in Eclipse ?

How to set up Java Hibernate with MySQL in Eclipse - featured image

Hibernate+MySQL+Java+Eclipse: How ? Today we are going to see how to integrate Hibernate with mysql in Java using Eclipse.   PreRequisite: 1. Ensure you have Eclipse Juno [you can also have some other version of eclipse, but we installed hibernate tools in eclipse Juno only. I would recommend you to download eclipse juno to install hibernate tools]. 2. Hibernate tools

249 total views, 1 views today

» Read more

How to create a hibernate mapping XML file automatically ?

How to create a hibernate mapping XML file automatically using hibernate tools?   In hibernate ORM (Object Relational Mapping) we have to use either XML or annotations to map the Java POJO with table entities.   Everyone is thinking that mapping using XML is very difficult, but it is very simple in eclipse.   Prerequisite:  Hibernate tools should be installed

148 total views, no views today

» Read more

How to create a sessionfactory in hibernate 4.3.6?

How to create sessionfactory in hibernate 4.3.6?

How to create a sessionfactory in hibernate 4.3.6? Hibernate is a ORM (Object Relation mapping) framework and creating a sessionfactory is very basic one to start with hibernate. Before creating sessionfactory, it is very important to know and understand what is sessionfactory ? If you are new to hibernate then you may not knowing this, but if you have worked

321 total views, 5 views today

» Read more

Difference between session.get() vs session.load() in hibernate ?

Difference between session.get() vs session.load() in hibernate ? Both are used to retrieve the objects from the database.   Differences: 1. session.load() will return the hibernate proxy object, but session.get() will return real object. 2. session.load() will not hit the database, but session.get() will hit the database all the time. 3. session.load() will throw object not found exception when no

172 total views, no views today

» Read more

Hibernate Criteria Duplicate Records Issue [Solved]

Hibernate Criteria Duplicate Records Issue: Problem: Duplicate same records with hibernate join. In Hibernate if we did join, we may get duplicates sometime. Below are the possible ways to resolve the duplicate same record value issue, Possible Solutions: 1. criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); 2. criteria.setProjection(Projections.distinct(Projections.property(“id”))); 3. criteria.setProjection(Projections.distinct(Projections.id())); Recommended Solution: criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); If nothing is working then change the list to set, so that duplicates

215 total views, 1 views today

» Read more

[solved] org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session

org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: Meaning of this exception:If we are trying to save the same identifier (primary key) with different session we will get this error. How I solved ?I have used Transaction and session previosly, then I replaced those things with getHibernateTemplate, getHibernateTemplate().saveOrUpdate(myBean); Then issue got resolved. In

188 total views, no views today

» Read more

[solved] an annotationconfiguration instance is required to use mapping class

An annotationconfiguration instance is required to use mapping class Error: an annotationconfiguration instance is required to use mapping class Solution: 1. Ensure you have hibernate-annotations.jar file 2. Create the sessionfactory using new AnnotationConfiguration() not using new Configuration(). Eg: SessionFactory hibernateConfig1 = new AnnotationConfiguration().configure(“hibernate1.cfg.xml”).buildSessionFactory(); Recommended Books: 231 total views, no views today

231 total views, no views today

» Read more
1 2 3