From: The R. <the...@gm...> - 2007-04-23 10:56:36
|
Hi, Am using Hibernate with Java Persistence API. The question, in short is: How do I restrict the Java Persistence API to access rows only from one table & not from any other table i.e. Even though it might require access to other tables, it should access rows only from one particular table. How to enforce this? In detail, this' the problem: We have a data model like this: Level 1 class ......within this there is Level 2 class ............within Level 2, there is Level 3 class it's just like XML data where we have a tag within another tag & so on. The root tag is Level1 & the tags in the next level are Level2, let's assume...and so on. i.e. an instance of Level1 class can contain many objects of Level2 within it. And an instance of Level2 class can contain many objects of Level3 within it. Within the Level1 class, we have methods to fetch corresponding objects from Level2. & the same for Level2 class. So, using Java Persistence API, when accessing instances of Level1, they automatically fetch corresponding instances of Level2 & Level3. Level1 has a corresponding table in the database called Level1. & the same with Level2 & Level3. How do I restrict the Java Persistence API to fetch objects only from Level1 table & not from other tables? Thanks. |
From: Dmitri C. <di...@co...> - 2007-04-23 20:57:56
|
Hi, I think you'd be better off here: http://forum.hibernate.org/ The answer to your question is lazy loading, see http://www.hibernate.org/hib_docs/v3/reference/en/html/performance.html#performance-fetching-lazy cheers, dim On 4/23/07, The Rhythmic <the...@gm...> wrote: > > Hi, > > Am using Hibernate with Java Persistence API. > > The question, in short is: > How do I restrict the Java Persistence API to access rows only from one > table & not from any other table i.e. Even though it might require access > to other tables, it should access rows only from one particular table. How > to enforce this? > > In detail, this' the problem: > > We have a data model like this: > > Level 1 class > ......within this there is Level 2 class > ............within Level 2, there is Level 3 class > > it's just like XML data where we have a tag within another tag & so on. > The root tag is Level1 & the tags in the next level are Level2, let's > assume...and so on. > > i.e. an instance of Level1 class can contain many objects of Level2 within > it. And an instance of Level2 class can contain many objects of Level3 > within it. Within the Level1 class, we have methods to fetch corresponding > objects from Level2. & the same for Level2 class. So, using Java Persistence > API, when accessing instances of Level1, they automatically fetch > corresponding instances of Level2 & Level3. Level1 has a corresponding table > in the database called Level1. & the same with Level2 & Level3. How do I > restrict the Java Persistence API to fetch objects only from Level1 table & > not from other tables? > > Thanks. > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > hibernate-devel mailing list > hib...@li... > https://lists.sourceforge.net/lists/listinfo/hibernate-devel > > |
From: The R. <the...@gm...> - 2007-04-25 13:25:01
|
Thanks to all for your replies. Lazy loading does the trick! On 4/24/07, Dmitri Colebatch <di...@co...> wrote: > > Hi, > > I think you'd be better off here: http://forum.hibernate.org/ > > The answer to your question is lazy loading, see http://www.hibernate.org/hib_docs/v3/reference/en/html/performance.html#performance-fetching-lazy > > > cheers, > dim > > > On 4/23/07, The Rhythmic <the...@gm...> wrote: > > > Hi, > > > > Am using Hibernate with Java Persistence API. > > > > The question, in short is: > > How do I restrict the Java Persistence API to access rows only from one > > table & not from any other table i.e. Even though it might require > > access to other tables, it should access rows only from one particular > > table. How to enforce this? > > > > In detail, this' the problem: > > > > We have a data model like this: > > > > Level 1 class > > ......within this there is Level 2 class > > ............within Level 2, there is Level 3 class > > > > it's just like XML data where we have a tag within another tag & so on. > > The root tag is Level1 & the tags in the next level are Level2, let's > > assume...and so on. > > > > i.e. an instance of Level1 class can contain many objects of Level2 > > within it. And an instance of Level2 class can contain many objects of > > Level3 within it. Within the Level1 class, we have methods to fetch > > corresponding objects from Level2. & the same for Level2 class. So, using > > Java Persistence API, when accessing instances of Level1, they automatically > > fetch corresponding instances of Level2 & Level3. Level1 has a corresponding > > table in the database called Level1. & the same with Level2 & Level3. How do > > I restrict the Java Persistence API to fetch objects only from Level1 table > > & not from other tables? > > > > Thanks. > > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by DB2 Express > > Download DB2 Express C - the FREE version of DB2 express and take > > control of your XML. No limits. Just data. Click to get it now. > > http://sourceforge.net/powerbar/db2/ > > _______________________________________________ > > hibernate-devel mailing list > > hib...@li... > > https://lists.sourceforge.net/lists/listinfo/hibernate-devel > > > > > |