File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Is it ok to drop the foreign keys created by EJB 3 on the database? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Is it ok to drop the foreign keys created by EJB 3 on the database?" Watch "Is it ok to drop the foreign keys created by EJB 3 on the database?" New topic
Author

Is it ok to drop the foreign keys created by EJB 3 on the database?

raminaa niilian
Ranch Hand

Joined: Jul 14, 2005
Posts: 551
Hi,

Can you please let me know what will happen if I delete the foreign keys created by EJb 3 in my database?

Thanks
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2516
    
  10

raminaa niilian wrote:Hi,

Can you please let me know what will happen if I delete the foreign keys created by EJb 3 in my database?

Thanks
Drop the columns, or drop the constraints?


OCUP UML fundamental and ITIL foundation
youtube channel
raminaa niilian
Ranch Hand

Joined: Jul 14, 2005
Posts: 551

The constraint and not the columns.

Thanks
alice zhu
Greenhorn

Joined: Jan 27, 2010
Posts: 5
raminaa niilian wrote:
The constraint and not the columns.

Thanks


I'm not sure about the scenario. But if you drop the constraint, the jpa won't be able to retrieve the attribute as an instance of the entity the foreign key references. ie, entity A has an attribute person which is an int that references to the Id of entity Person. If the foreign key is lost, person will be an int instead of being an instance of Person. Is that what you mean?
raminaa niilian
Ranch Hand

Joined: Jul 14, 2005
Posts: 551
alice zhu wrote:
raminaa niilian wrote:
The constraint and not the columns.

Thanks


I'm not sure about the scenario. But if you drop the constraint, the jpa won't be able to retrieve the attribute as an instance of the entity the foreign key references. ie, entity A has an attribute person which is an int that references to the Id of entity Person. If the foreign key is lost, person will be an int instead of being an instance of Person. Is that what you mean?



Do you mean that JPA uses the FK themselves to make multiplicity relations? I think they use the related database column to do that and not the FK itself. My doubt is that dropping the fks may cause other unexpected problems.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is it ok to drop the foreign keys created by EJB 3 on the database?