Results 1 to 2 of 2
  1. #1
    jperson is offline Member
    Join Date
    Jan 2010
    Posts
    61
    Rep Power
    0

    Default problem in hibernate

    Java Code:
    import javax.swing.JOptionPane;
    import org.hibernate.Session;
    import org.hibernate.SessionFactory;
    import org.hibernate.Transaction;
    import org.hibernate.cfg.Configuration;
    
    public class insert {
     
        public static void main(String[] args) {
           try {
                Configuration cfg = new Configuration();
                SessionFactory factory = cfg.configure().buildSessionFactory();
                Session session = factory.openSession();
    
               String id = JOptionPane.showInputDialog("enter your id");
               String entity = JOptionPane.showInputDialog("enter your entity");
               String record = JOptionPane.showInputDialog("enter your record");
    
                Main m = new Main();
    
                m.setId(id);
                m.setEntity(entity);
                m.setRecord(record);
    
                Transaction tx = session.beginTransaction();
                session.saveOrUpdate(m);
                tx.commit();
                JOptionPane.showMessageDialog(null, "succesfully inserted");
    
                session.close();
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e);
            }
        }
    }
    Java Code:
    <?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="Main" table="ifc">
        <id column = "id" name="id" type="string"/>
        <property column = "entity" name="entity" type="string"/>
        <property column = "record" name="record" type="string"/>
      </class>
    </hibernate-mapping>
    my problem when i set values to id, entity and record - i have this exception

    Cannot insert the value NULL into column 'record'

    although i set value to it

    please help me ?

  2. #2
    AadiSri is offline Member
    Join Date
    Dec 2010
    Posts
    4
    Rep Power
    0

Similar Threads

  1. crieteriaSearch problem (hibernate)
    By asshwy in forum JDBC
    Replies: 3
    Last Post: 05-07-2010, 11:21 AM
  2. Hibernate problem in Eclipse
    By maikki in forum Eclipse
    Replies: 1
    Last Post: 03-19-2010, 12:24 AM
  3. composite-id problem hibernate
    By javadev in forum JDBC
    Replies: 14
    Last Post: 07-27-2009, 06:30 PM
  4. Hibernate cache problem
    By jispat in forum New To Java
    Replies: 0
    Last Post: 12-29-2008, 11:18 AM
  5. problem in hibernate need help!
    By jrgahan in forum Advanced Java
    Replies: 0
    Last Post: 05-22-2008, 09:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •