
Saturday, December 28, 2013
Hibernate Framework flow

The general flow of Hibernate framework while interacting with the Database is:Example Program: // creating the Configuration object Configuration config = new Configuration(); config.configure(); ...
Exception in thread "main" org.hibernate.TypeMismatchException: Provided id of the wrong type for class com.ranga.pojo.Order. Expected: class java.lang.Long, got class java.lang.Integer

Exception in thread "main" org.hibernate.TypeMismatchException: Provided id of the wrong type for class com.ranga.pojo.Order. Expected: class java.lang.Long, got class java.lang.IntegerProblem: While passing primary key value in either load() or get() or byId() the value you passed is integer. but it expecting long value.Solution: You need to pass the long value instead of integ...
org.hibernate.MappingException: Unknown entity:

org.hibernate.MappingException: Unknown entity: com.ranga.mapping.StudentProblem: In configuration file you are not added Student class or wrong path.Solution: Add the proper Mapping file in configurati...
org.hibernate.MappingException: Could not determine type for: String, at table: Persons, for columns: [org.hibernate.mapping.Column(FirstName)]

org.hibernate.MappingException: Could not determine type for: String, at table: Persons, for columns: [org.hibernate.mapping.Column(FirstName)]Problem: In Mapping, the type what you specified that the first character will be in Upper case. In the above exception, type will be String.Solution: In hibernate mapping file, use type string instead of String because in hibernate, the type will be case sensitive.Java typeMapping typeANSI SQL...
Exception in thread "main" java.lang.ExceptionInInitializerError

Could not parse mapping document from resource com/ranga/Person.hbm.xmlException in thread "main" java.lang.ExceptionInInitializerErrorProblem: In Mapping file DTD information is not added or wrong DTD information you are given.Solution: Add the proper DTD information in mapping file(Person.hbm.x...
java.lang.UnsupportedOperationException: The application must supply JDBC connections.

Exception in thread "main" java.lang.UnsupportedOperationException: The application must supply JDBC connections.Problem: while setting jdbc connection property by using annotation configuration we need to add hibernate in preceed of property.AnnotationConfiguration config = new AnnotationConfiguration().addAnnotatedClass(User.class); config.setProperty("connection.driver_class", "oracle.jdbc.driver.OracleDriver");...
java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException

Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/ehcache/CacheExceptionProblem: You need to add ehcache*.jar(for example ehcache.2.7.4.jar) file into your classpath.Solution: Add the ehcache*.jar file to your class path or specify the maven dependency in pom.xml file.<dependency> <groupId>net.sf.ehcache</groupId> <artifactId>ehcache</artifactId> <version>2.7.4</version></dependency>...
Friday, December 27, 2013
java.lang.NoClassDefFoundError: net/sf/ehcache/util/Timestampe

Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/ehcache/util/Timestamper at org.hibernate.cache.ehcache.internal.regions.EhcacheDataRegion.<init>(EhcacheDataRegion.java:86) at org.hibernate.cache.ehcache.internal.regions.EhcacheTransactionalDataRegion.<init>(EhcacheTransactionalDataRegion.java:74) at org.hibernate.cache.ehcache.internal.regions.EhcacheEntityRegion.<init>(EhcacheEntityRegion.java:58)...