• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate help

 
Farhan Chowdhury
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to write some data to my database. I get the following error:

Dec 21, 2006 10:29:24 AM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.0.5
Dec 21, 2006 10:29:24 AM org.hibernate.cfg.Environment <clinit>
INFO: loaded properties from resource hibernate.properties: {hibernate.connection.username=root, hibernate.connection.password=****, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=org.hibernate.dialect.MySQLDialect, hibernate.connection.url=jdbc:mysql://localhost/mecap, hibernate.connection.driver_class=org.gjt.mm.mysql.Driver}
Dec 21, 2006 10:29:24 AM org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Dec 21, 2006 10:29:24 AM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Dec 21, 2006 10:29:24 AM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Dec 21, 2006 10:29:24 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
An AnnotationConfiguration instance is required to use <mapping clazz="com.marketecho.mecap.Users"/>
Hello

Exception in thread "main" java.lang.NullPointerException
at com.marketecho.mecap.WritingRecord.main(WritingRecord.java:38)

My code is the following:

It gives me null pointer exception at line session.flush().

[ Edited to use code tags - Paul Sturrock ]
[ December 21, 2006: Message edited by: Paul Sturrock ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the Session is null. Did either of these lines work?


This line:

An AnnotationConfiguration instance is required to use <mapping clazz="com.marketecho.mecap.Users"/>

suggests they didn't.
[ December 21, 2006: Message edited by: Paul Sturrock ]
 
Farhan Chowdhury
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What can I do about it? any suggestion please.
 
Farhan Chowdhury
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
It catches exception prints out the following line
An AnnotationConfiguration instance is required to use <mapping clazz="com.marketecho.mecap.Users"/>
Then since session is null, it gets null pointer excepetion at
line session.flush();

Any suggestion what can I do?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic