Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Where to maintain Transitive Closure of a DAG?

Some options may be,

- Use a Factory class in your application to create the Edges and also
create the other object.
- You might be able to use prePersist to create the other object, or you may
be able to use EclipseLink DescriptorEvents and directly call insertObject()
on the UnitOfWork in the pre/postInsert event.
- You may be able to use a insert trigger in the database to insert the
other object.


Jaka Jančar wrote:
> 
> Hi!
> 
> I have a directed acyclic graph, represented with entities like this:
> 
> class Vertex {
>   int id;
> }
> 
> class Edge {
>   int inVertexId;
>   int outVertexId;
> }
> 
> In order to quickly find out whether a vertex is reachable from
> another vertex, I need to maintain a transitive closure (an "is
> reachable" relation):
> 
> class TransitiveEdge {
>   int inVertexId;
>   int outVertexId;
> }
> 
> I of course do not want to burden the user (of the Edge class) with
> this. Whenever an edge is added or removed, I need to update the the
> transitive closure.
> 
> JPA apparently does not allow the use of EntityManager in
> @PostPersist/@PostRemove.
> 
> Is there any other way of achieving this automatically?
> 
> Regards,
> Jaka
> 
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/Where-to-maintain-Transitive-Closure-of-a-DAG--tp23671941p23725245.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top