For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub
- This topic has 1 reply, 2 voices, and was last updated 19 years, 9 months ago by
Riyad Kalla.
-
AuthorPosts
-
easyuploaderMemberhai, I am developing my first web application using hibernate and postgresql as the database. I had created a database in postgresql and had two colums in it. when i am trying to insert values into that databse through my following program,
import net.sf.hibernate.*;public class HibernateTest {
public static void main(String[] args) {
Employee message = new Employee();
message.getClass();
message.setEmployeeid(“14”);
message.setEmpname(“happy”);
Transaction tx=null;
try {
Session session = SessionManager.currentSession();
tx = session.beginTransaction();
session.save(message);
tx.commit();
System.out.println(“Save successful.”);
} catch (HibernateException e) {
try {
tx.rollback();
} catch (HibernateException e1) {
System.out.println(e1);
}
System.out.println(e.toString());
e.printStackTrace();
if(e.getCause()!= null)
System.out.println(e.getCause().getMessage());
}
finally {
try {
SessionManager.closeSession();
} catch (HibernateException e2) {
}
}
}
}When i am trying to run this application i am getting the following error
log4j:WARN No appenders could be found for logger (net.sf.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
net.sf.hibernate.exception.SQLGrammarException: Could not save object
at net.sf.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:59)
at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:30)
at net.sf.hibernate.impl.SessionImpl.convert(SessionImpl.java:4110)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:792)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:747)
at com.nanna.hibernate.HibernateTest.main(HibernateTest.java:32)
Caused by: org.postgresql.util.PSQLException: ERROR: column “employeeid” does not exist
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1512)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1297)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:430)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:346)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:250)
at net.sf.hibernate.id.IncrementGenerator.getNext(IncrementGenerator.java:68)
at net.sf.hibernate.id.IncrementGenerator.generate(IncrementGenerator.java:42)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:774)
… 2 more
net.sf.hibernate.exception.SQLGrammarException: Could not save object
ERROR: column “employeeid” does not existBut there is the colum employeeid in the database. I could not figure out where i went wrong. please help me.
May 10, 2006 at 2:21 pm #251879
Riyad KallaMemberPaste the CREAET TABLE statement for your table and the hbm.xml file for us to see.
-
AuthorPosts
