• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Relationships in DTO need foreign keys to allow null?

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

we have an database design problem on mySQL using JBoss. We are using CMP, Autoincrement and InnoDB relationships. The Problem of our design qzestion is the following:
As we use EJB as abstaction layer and tranfer data from client to server by DTO, we have a "dirty flag" that marks our DTO as modified by the client. Then our serverside logic has to create/modify these entities. No problems until here. But when we have related data, it is impossible to create the relationship witout getting the database table id becaouse of the foreign constraint. Threrfore we allowed to insert data with foreign key null which is quite not very nice! Is there any possibility or JBoss mechanism to tell the container to create constrained data objects in one operation including the correct foreign references. So we would not have to do it unsecure in two steps (the foreign key = null way without DB savety or access to the DB layer since object abstaction is not any more given in a elegant form).

Thanks for any reply,
Dennis
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I understand your problem correctly... then you can use the <insert-after-ejb-post-create> configuration feature (JBoss 3.2.2 and above) and set the non-null foreign keys in ejbPostCreate().

-Ade Barkah
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that what Ade said would be the solution for most major databases,
but as fair as i know, mysql doesn't support the insert-after-ejb-post-create feature.

You can try though, if you make it work, please let me know.
 
reply
    Bookmark Topic Watch Topic
  • New Topic