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 IsEntityRemovalAllowed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "IsEntityRemovalAllowed" Watch "IsEntityRemovalAllowed" New topic
Author

IsEntityRemovalAllowed

Yaron Rel
Greenhorn

Joined: Aug 04, 2009
Posts: 20
Hi,
I am trying to find a way to know if a removal of an entity is allowed.
is there any simple way to do that?
Thanks
Yaron


The method signature:



I have 2 Stateless session bean that I can use each of them:
1. CMT bean with injected entity manager.
2. BMT bean with entity manager that is being created by entity manager factory.

Yaron Rel
Greenhorn

Joined: Aug 04, 2009
Posts: 20
I found some ways to know if I am allowed to remove an entity.
The entity removal can be disallowed due to constraints on the DB record that represent the entity to be removed.
I must admit that I don't love this ways because I rely on condition of exceptions, but this is what I got.
Here are 3 ways:
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: IsEntityRemovalAllowed
 
Similar Threads
How to inject EntityManager via setter in spring
EntityManager is null when I try to use it straight from filter servlet
design decision: variation of session fassade
NullPointer with EntityManager in Entity Bean
Database connection using JBoss Seam & JBoss Tools for Eclipse