Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
JSP - A mailing list about Java Server Pages specification and reference
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
EJB CMP 2.0 and Referential Integrity.

EJB CMP 2.0 and Referential Integrity.

2004-11-19       - By Markus Fuchs

 Back
Reply:     1     2     3     4     5     6     7  

Vikram,

Please excuse my late reply. AFAIK, there's no automatic way to prevent an
Entity from being deleted as long as it's still referenced. But you can always
implement this restriction in the ejbRemove callback method.

Foreign key constraints in the database prevent a referred row from being
deleted by raising an error. The EJB container especially provides managed
relationships and dependency management to prevent these errors.

Implementing the delete-restriction in your bean is much better than catching
and handling foreign key constrain vioaltions from the database.

-- markus.

"Naik, Vikram ( eBiz Mumbai )" wrote:

> Hi Markus,
>
> Thanks for your response.
> Yes, container does nullify the foreign key column(s) in Entity A. Now my
question is, say we want to restrict the deletion of B, as its being refernced
by Entity A.
> Currently we achieve that using the foreign key constraint at database level.
For such relations we define, foreign key constraints which restricts the
deletion on an entity as its being referenced.
> So are there any other ways to do so. If contianer can handle cascade delete,
shouldn't it be able to handle such similar constraints ??
>
> Vikram.
>
>         -- --Original Message-- --
>         From: Markus Fuchs [mailto:Markus.Fuchs@(protected)]
>         Sent: Mon 11/1/2004 4:24 AM
>         To: J2EE-INTEREST@(protected)
>         Cc:
>         Subject: Re: EJB CMP 2.0 and Referential Integrity.
>
>
>
>         "Having a Many To One relationship between A and B means that the
foreign key must be defined in B's table"
>
>         It's actually the other way round:
>
>         Having a Many-To-One relationship between A and B means that the
foreign key column(s) are defined in A's table. Removing B must automatically
nullify A's foreign key column(s). The container guarantees this behavior, even
for
>         one-way relationships.
>
>         -- markus.
>
>         Markus Fuchs wrote:
>
>         > Hi Vikram,
>         >
>         > Having a Many To One relationship between A and B means that the
foreign key must be defined in B's table, so removing Entity B has no effect on
A's representation in the database. The EJB Spec. defines relationships to be
>         > "managed", i.e. the container must remove Entity B from the
relationship to Entity A in memory. (See for instance EJB 2.1 Spec, sec. 10.3.7
.5).
>         >
>         > B's cascadeDelete setting or foreign keys in the database have no
influence on this behavior. The container will handle the described situation
automatically.
>         >
>         > Regards,
>         >
>         > -- markus.
>         >
>         > "Naik, Vikram ( eBiz Mumbai )" wrote:
>         >
>         > > Thanks for your response.
>         > >
>         > > Thats, true container does take care of cascade delete, but what
happens in the following scenario:
>         > >
>         > > Say we have a Many to One aggregate uni-directional CMR relation
between Entity A and Entity B.
>         > >
>         > > Now, if we try to delete Entity B which is still be referred/
referenced by Entity A, the container just deletes the Entity B. unless we
define a foreign key constraint at database level, that would restrict the
deletion.
>         > >
>         > > Can container handle this stiuation, even if we dont defined
foreign key constraints at database level ?
>         > > Is this something that developer has to take care of ?
>         > >
>         > >
>         > >
>         > >         -- --Original Message-- --
>         > >         From: Guy Katz [mailto:gkatz@(protected)]
>         > >         Sent: Sun 10/31/2004 7:54 AM
>         > >         To: J2EE-INTEREST@(protected)
>         > >         Cc:
>         > >         Subject: Re: EJB CMP 2.0 and Referential Integrity.
>         > >
>         > >
>         > >
>         > >         if you use CMR
>         > >         referential intergrity is a built in part of the game.
>         > >         depending on the nature of your CMR definition
(multiplicity etc..)
>         > >         the container will take care of it as long as you call
your CMR methods.
>         > >
>         > >
>         > >         -- --Original Message-- --
>         > >         From: A mailing list for Java(tm) 2 Platform, Enterprise
Edition
>         > >         [mailto:J2EE-INTEREST@(protected)]On Behalf Of Naik,
Vikram ( eBiz
>         > >         Mumbai )
>         > >         Sent: Saturday, October 30, 2004 7:47 PM
>         > >         To: J2EE-INTEREST@(protected)
>         > >         Subject: EJB CMP 2.0 and Referential Integrity.
>         > >
>         > >
>         > >         Hello,
>         > >
>         > >         What are the different ways to have referential integrity
for your data,
>         > >         when the persistence is done using EJB CMP 2.0 ?
>         > >
>         > >         We are using database foreign key constraints along with
CMR to achieve the
>         > >         same ?
>         > >
>         > >         Would appreciate all your thoughts on the above.
>         > >
>         > >         Regards,
>         > >         Vikram.
>         > >
>         > >         =========================================================
==================
>         > >         To unsubscribe, send email to listserv@(protected) and
include in the body
>         > >         of the message "signoff J2EE-INTEREST".  For general help
, send email to
>         > >         listserv@(protected) and include in the body of the
message "help".
>         > >
>
>         =====================================================================
======
>         To unsubscribe, send email to listserv@(protected) and include in
the body
>         of the message "signoff J2EE-INTEREST".  For general help, send email
to
>         listserv@(protected) and include in the body of the message "help".
>

===========================================================================
To unsubscribe, send email to listserv@(protected) and include in the body
of the message "signoff J2EE-INTEREST".  For general help, send email to
listserv@(protected) and include in the body of the message "help".

©2008 junlu.com - Jax Systems, LLC, U.S.A.