|
Hy, I'm used middlegen to generate code from a database schema, I has InnoDB tables into a mysql database, In particular, I have one table with an autoincrement pk field (well, in fact, all the tables have an autoincrement pk field), wich is causing me some problems. This table, has a child table (1 - 0..N Relation) well, thay work fairly well if you create first one row int he parent table, then you manage to get its local instance (I call them from a session bean, so I use the local interfaces), and then insert the childs wioth this local object in the create call. The problem arises as, from the client app, the user can create a new structure (a new parent with new childs) and then I need to create the parent (this step its ok) an then get this newly created parent and insert the childs, this second step is what is causing me problems. First, the aprent create method returns me null, The bean returns a PKFactura (the table is called Factura) but the method in the localhome interface (generated with XDoclet using the tgas generated with middlegen) returns a FacturaLocalHome object, I thinks its ok as Jbosss deploys it ok and I don't know what the specification says about this, anyway, as I said the create method returns null, nor the PK nor the newly created entity. So, here arises the problem, I have no way to get this entity without user intervention, as no other field is unique, I dont know the pk the mysql engine asigned the new parent row. The only way i think I have to get the pk it with the SELECT LAST_INSERTED_ID() SQL sentence, I havent tested yet but I'm not sure it will work as as far as I know:
Well, does anyone knows if the LAST_INSERTED_ID() aproach will do???????? --
|
<<inline: logo_stratesys.jpg>>
smime.p7s
Description: S/MIME Cryptographic Signature
