Sounds odd as the create should return the entity bean.
Attach the relevant code and build file.

Tim
On Thu, 2004-01-22 at 11:23, Jos� Manuel Molina Pascual wrote:
> 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:
>       * It returns the last inserted autoincrement value on a
>         connection base, so if Jboss doesn't employ the same
>         connection to insert the parents and the childs, i wont do, or
>         if the same connection is used by jboss to insert one parent,
>         then another parent , then the childs from the first
>         parent.........    it won't do.
> In fact I'm not sure about the behaviour of jboss at this point, th
> parent and the childs, are inserted in the same method of the wrapper
> session bean, maybe, its done into one transaction, and so inside the
> same connection.
> 
> 
> Well, does anyone knows if the LAST_INSERTED_ID() aproach will
> do????????
> 
> 
> -- 
> Jos� Manuel Molina Pascual
> 
> [EMAIL PROTECTED]
> 
> Stratesys Consulting 
> C/ Juan de Mena, 6
> Madrid 28014
> Tel (+34) 91 360 49 60
> 



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
middlegen-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/middlegen-user

Reply via email to