• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot insert into db with hibernate HELPPP :(

 
Adriana Lazar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, i am using oracle 10 g and i am trying to insert into table Comments a new comment, but it doesn't insert anything!
Please help I really need to solve this problem

This is what I get:

03:46:24,765 DEBUG SQL:401 - select max(id) from comments
Hibernate: select max(id) from comments
03:46:24,906 DEBUG SQL:401 - insert into comments (objectiveId, comments, id) values (?, ?, ?)
Hibernate: insert into comments (objectiveId, comments, id) values (?, ?, ?)

and THAT'S IT...no errors no nothing it just stops.

mappings:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<class name="home.db.Comments" table="comments">
<id name="id" column="id" type="java.lang.Integer">
<generator class="increment"/>
</id>
<property name ="objectiveId" column="objectiveId" type="java.lang.Integer"/>
<property name="comments" column="comments" type="java.lang.String" />
</class>
</hibernate-mapping>


code called:

main {
DbManager dm = new DbManager();
dm.addComment("1", "aaaaaaaaa");
}

public void addComment(String id, String comment) {
Transaction tx = null;
Session session = null;
Comments comments = new Comments();
comments.setComments(comment);
comments.setObjectiveId(Integer.parseInt(id));
try {
session = InitSessionFactory.getInstance().getCurrentSession();
tx = session.beginTransaction();
session.save(comments);
tx.commit();

} catch (HibernateException e) {
e.printStackTrace();
if (tx != null && tx.isActive())
tx.rollback();

}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic