If you're using Hibernate or JPA, it's as simple as calling the following after a save:
Long newId = e8workReport.getId(); Hope this helps, Matt On Wed, Sep 29, 2010 at 9:58 PM, itsdipak <itsdi...@gmail.com> wrote: > > Hi, > How to get id for the newly inserted record? I want to save that id in > another table. > > In My action, in save method > > e8workReportManager.save(e8workReport); > > > After this i want to insert this newly created id in e2work table. > currently what im doing is- > List<E8workReport> e8mList = e8workReportManager.getAll("order by id DESC > LIMIT 1"); > (added getAll(String) in generic manager to get ordered list) > then > Long newid = e8mList .get(0).getId(); > > then i m saving this 'newid' in required table. > I know this is wrong and lengthy way in doing. > Please suggest me the correct way of doing it. > > Waiting for reply > > > -- > View this message in context: > http://appfuse.547863.n4.nabble.com/Get-id-of-newly-inserted-record-tp2720150p2720150.html > Sent from the AppFuse - User mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net > For additional commands, e-mail: users-h...@appfuse.dev.java.net > >