-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: List of all the tables a persistable entity can affect
PostPosted: Thu Jul 27, 2017 8:49 am 
Newbie

Joined: Thu Jul 27, 2017 8:09 am
Posts: 1
Hibernate Version: 3.2.7
Get the list of all the tables a persistable entity can affect

I want to get the list of all the tables, any action on a persistable entity can affect, I have tried the following approach:

String[] Function(String entityName, Session)
1. Add entityName to a list.
2. Iterate over list. For each in list
    i. To handle cycle, If entityName has already been processd, move to process next item in the list.
    ii. Get ClassMetadata using sessionFactory.getClassMetadata(entityName).
    iii. If metaData is null, move to process next item in the list.
    iv. If metaData is instance of AbstractEntityPersister, get the table name of the entity using persister.getTableName() and add to response array. Proceed to check if
    there are associations.
    v. Get the list of properties, For each property,
      a. Load the Type of the property
      b. If type is Association as well as Entity,add entityType.getAssociatedEntityName() to the list
      If type is Association as well as Collection, add colltype.getAssociatedEntityName(factoryImplementor) to the list
      If type is component, add componentType.getReturnedClass().getName() to the list
    vi. Mark the entityName processed.


I am getting stuck when a property is mapped like this:
<array table="">
This property is identified as a collection but getAssociatedEntityName method fails with exception message: "collection was not an association". Then, I tried to handle for such types with if(type is ArrayType), I am not able to figure out how to get the associated table name in that case.

Since this, I have also learnt that getClassMetadata has been deprecated. Please suggest as to how to make this possible. I am yet to try with EntityManagerFactory.


Top
 Profile  
 
 Post subject: Re: List of all the tables a persistable entity can affect
PostPosted: Thu Jul 27, 2017 11:30 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Hibernate 3.2.7 is too old and not supported anymore.

For Hibernate 5, check out this article as it might help.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.