Announcement Announcement Module
Collapse
No announcement yet.
Error saving a object using getCurrentSession().save(obj) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error saving a object using getCurrentSession().save(obj)

    I'm trying to persist a object with the following code:

    Code:
    sessionFactory.getCurrentSession().save(myObject)
    myObject is a instance of Class MyObject & most of the fields are set from Spring form. Only the columns which have default values defined in MySQL are not set e.g. ID

    Code:
    @Id
       @GeneratedValue(strategy = IDENTITY)
       @Column(name = "MyObjectID", unique = true, nullable = false)
       public Integer getMyObjectID() {
          return this.myObjectID;
       }
    There are other fields too like current_TS which has default in MYSQL.

    But upon execution i get the following error:

    Code:
    org.hibernate.AssertionFailure: null id in .............. entry (don't flush the Session after an exception occurs)
    How to persist an object without setting it's default values so that MySQL sets those default values. Please guide.
    I'm stuck...please help.

  • #2
    The issue is resolved now. Thanks a lot.

    Comment


    • #3
      i am facing the same issue. how did u resolve the issue?

      Comment

      Working...
      X