retrieve new row's auto-increment key from dataprovider
** cross posted on SDN JSC Forum and Netbeans J2EE Nabble forum **
I have a page that is bound to a MySQL table rowset or, alternately, a new (append()'ed) row. The row's Primary Key is a MySQL auto-increment Integer (translates to a Long.) After commit()'ing the the new row to the database, how would I then get the new row's ID (fieldname "ID")? If I refresh() the dataprovider and try to get the value an error is thrown.
Some background: The dataprovider's backing rowset has a query parameter for the ID field. I set it to "0" if the page is creating a new row or I set it to the unique ID if the page is displaying an existing row. After the new row is committed, I need the new ID set the query parameter and synch up related rows in different tables that are keyed off the ID in this (master) table. I'd like to do this without "guessing" what the ID would be in advance as that method isn't foolproof in heavy usage.
Additionally, it strikes me as a useful workaround if the unique ID was a UUID (mySQL UUID() function) that does not run the risk of any concurrency issues. Has anyone used this solution in VWP? How would I make the call for the underying DB (in this case MySQL, but could be anything) to generate the UUID? Is the call DB specific or is there a JDBC equivalent?
UPDATE: never mind the GUID question, I can use the java.rmi.dgc.VMID class to autogenerate unique GUID's for this purpose. Being from a Lotus Notes background, I'm used to the power and flexibility such Unique ID's bring to the app. dev's portfolio.
Thanks in adv. for any help .
-Jake
Message was edited by:
jakeochs
[1683 byte] By [
jakeochsa] at [2007-11-27 4:29:03]

# 1
I have some experience with Lotus Notes/Domino as well. And I will tell you for small to medium size data driven web apps, Java EE takes 5-10 times more develop than it takes on Notes/Domino. Since we are developing COTS products, so we have no choice but to use freeware, otherwise there is no comparison on developer productivity. I think Java spec leads should learn from Notes/Domino. My 5 cents.
JSC/VWP is a step forward but they still have to go a long way compared to Visual Studio or Notes/Domino.
# 2
I pretty much agree with you wholeheartedly. My position has evolved a bit since I wrote this, but here's what I thought about JSF and Creator in '05:
http://jroller.com/page/jakeochs?entry=notes_second_act
Of course, Creator and VWP have evolved since then and Codegear has intro'd Delphi for PHP, but most of this still rings true.
-J
# 3
JSF together with JBoss Seam offers some real good possibilities to improve developer productivity. Right now, with JSF you can create forms where fields are persistent (saved in a database), but you have to write code to persist fields. In Notes/Domino, every field you drop in the form is automatically set to persist without writing a single piece of code. JBoss Seam aims to provide the missing glue to tie the JSF beans with business logic (EJB) and persistent layer (JPA). I think tools for Seam are still not mature. I would love to see JSC/VWB utilizing Seam. I know there is a NetBean plugin for Seam but it was written for old NetBeans (not VWP or JSC), so it doesn't work with the visual web pack where you can drag and drop JSF components.
# 4
I'm not exactly sure how it works, but I put in an enhancement request for VWP and persistence and I believe you can vote on the request to increase its popularity. The request is here: http://www.netbeans.org/issues/show_bug.cgi?id=103757 This is where Winston Prakash advised me to put it...
Getting persistence to automagically work in VWP/JSC in line with the new EJB 3.0 persistence API's would be great and pretty much put us where we want to be with regards to mimicking desired Notes abilities with JSF, no?
-J