Menu

Savinf unmodified bean

Help
Hamvil
2005-09-07
2013-04-25
  • Hamvil

    Hamvil - 2005-09-07

    I've just saw that this new release of sql2java do not saved an unmodified bean.

    However this features was usefull, at least for me, since I was used to create a new bean and then save it into the database in order to get the new id (for an autoincrement key)

    Now this is not possible anymore. I think that this change break the backward compatibility and it would be more clear to use a release version like 2.7

     
    • nr

      nr - 2005-09-10

      Hi,
      Sorry for the inconvenience. We decided to implement it after receiving several complaints about trying to save bean without any fields set leading to some errors.

      But you're right... we neglect to inform you properly.

      Here is a way to rollback this behavior:
      since sql2java is now template based you can configure the desired behavior by hacking on of our template.
      In your case, take a look at http://sql2java.sourceforge.net/copied/xManagerTemplate.vm
      And simply comment out the following lines in the save method:

              if (!pObject.isModified()) {
                  return pObject; // should not we log something ?
              }

      N.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.