troubleshooting Question

No data is inserted a Hibernate question.

Avatar of JianJunShen
JianJunShen asked on
JavaJava EE
4 Comments1 Solution297 ViewsLast Modified:
I am using spring and hibernate. I have a simple table item2 and user. I could fetch the user name but I could not insert item2 data. No exception is thrown.
public class Item2 implements Serializable {
      private static final long serialVersionUID = -6542055568633475091L;
      private Long iid;
      private String name;
      private String description;
      private Integer initprice;
And its hbm.xml file is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
                            "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                            "" >
<hibernate-mapping package="com.juhani.hiberSpring2.hibernate">
    <class name="Item2" table="item2">
        <id name="iid" column="iid" type="long">
            <generator class="native" />
        <property name="name" column="name" type="string" />
        <property name="description" column="description" type="string" />
        <property name="initprice" column="initprice" type="integer" />      
And I write a test application as follows:
public void saveItem2() throws Exception {
            bindResource(getSessionFactory(), new SessionHolder(getSession()));
            Item2 item = new Item2();
            item.setDescription("a good one");
But there is no data is inserted.  Why???
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros