- This topic has 17 replies, 3 voices, and was last updated 18 years, 11 months ago by
Brian Fernandes.
-
AuthorPosts
-
dapriettMemberHello – I am using the Create Hibernate Mapping to reverse engineer a JDBC datasource. I have an issue with one of the tables though, which looks something like this:
Table_A
Table_B_ID NUMBER
Table_C_ID NUMBERTable_B_ID & Table_C_ID are a composite primary key for that table, and they are each foreign keys to another table.
It creates a TableAId.java class which contains the composite of those keys, which is referenced in the TableA.java model class – which I guess makes sense.
What I don’t understand is why there isn’t a tableAs Hashset reference in the TableB.java and TableC.java model classes – since Table-A has references to those two tables. It seems like for some reason myEclipse ignores those Foreign keys because those columns are included in the primary key.
If anyone has any more info on it, it would be appreciated.
Thanks,
Dan
Haris PecoMemberDan,
There are any problems with tables with PK=FK – it will be resolved in 4.1.1 – Please send us your database and version – 4.1.1 will be released soon
Thanks
Brian FernandesModeratorDan,
Can you also have a look at the “Generate basic typed composite IDs” option on page 2 of the RE wizard? If you turn it on, you might get somthing closer to the pattern you are expecting.
Best,
Brian.
dapriettMemberThanks for your reply guys – I was able to resolve my problem. The problem was that I was generating that table (Table_A) separately because Table_B & Table_C use sequence ID generator where Table_A is assigned. I didn’t realize you could sent that individually per table, in the Configure reverse engineering details section.
After looking at that section I now have some new issues. I noticed there was a property name you can set for each column in a table, which caught my eye because I didn’t like the default naming it gave for some of the properties.
The issue I’m having is the property name doesn’t work – it doesn’t do anything. I’m thinking the issue has something to do with the fact that the property name I’m changing is for a colum which is a foreign key to another table. When I generate the table by itself, it works then, but then I don’t have the references to the other tables (instead of the reference table object, I just get the table ID).
If this is a known bug and/or there is a workaround for it, please let me know.
Thanks,
Dan
dapriettMemberForgot to add this, but the main reason why I want to set the column property names is in some tables I have multiple foreign key references to the same table.
For example:
<u>Table_A</u>
Table_B_ID1
Table_B_ID2By default, myeclipse will generate these objects in TableA.java:
private TableB tableB;
private TableB tableB_1;I would like to rename those automatically with something meaniful which I would setup in hibernate.reveng.xml settings.
Brian FernandesModeratorDan,
Thank you for the detail. I know what your problem is, but I’m afriad we do not support renaming the foreign key references just yet.
There is no timeline set for this feature, but I will add your report to the issue tracker. We will try and get this into a release post 4.1.1.Thanks,
Brian.
dapriettMemberIs there a way to tell myeclipse to use the name of the column, not the table class it references, as a base for the naming of foreign keys? For example, here’s a table of companies, which has a foreign key to itself for a parent company.
<u>Company</u>
Company_Id
Company_Name
Company_Address
Parent_Company_idI would prefer it named that foreign key reference as parentCompany intead of just Company – it would be less confusing.
Brian FernandesModeratorDan,
That too isn’t possible yet. We have it on our radar and support for that will likely make it to a release after the 4.1.1 release.
Sorry for the inconvenience caused, but I’m adding your report to the tracker so we can boost the priority of this feature.Best,
Brian.
dapriettMemberThanks for the quick reply – I appreciate your help. One more question – how do you use the “custom templates” option it has in the hibernate mapping wizard?
Brian FernandesModeratorDan,
Here is a link which should get you going:
https://www.genuitec.com/forums/topic/dao-template-support/#post-247432Do let us know if you need further assistance.
Best,
Brian.
dapriettMemberThanks – didn’t realize you could customize everything with this – very useful. I have one more question for you now. What are all the different variable references in the .vm files. Is there some sort of documentation you could forward me which contains all the defined global variables? This would be very useful. Thanks!
Brian FernandesModeratorDan,
Good question.
Name Contents $cfg The current Hibernate Configuration object. See Hibernate3 javadocs for available properties/methods. [Configuration.java] $c2h A Cfg2HbmTool. Contains a set of helper methods related to cfg to hbm conversion. See sourcecode and existing templates for available properties/methods [Cfg2HbmTool.java] $c2j A Cfg2JavaTool. Contains a set of helper methods related to cfg to java conversion. See sourcecode and existing templates for available properties/methods. [Cfg2JavaTool.java] $clazz A reference to the current PersistentClass or Component being processed. (In any class related template) [PersistentClass.java] $property A reference to the current Property being processed. (In any property related template) [org.hibernate.mapping.Property.java]
If you find any variables missing, let me know. I have mentioned the java files in which you can find more information if you wish to understand the inner-workings of these objects. You can find these files by browsing the Hibernate and Hibernate Tools source from the Hibernate CVS.
Best,
Brian.
dapriettMemberThanks for the info. Now I noticed in the many-to-one.hbm.va that it uses $property.name for the many-to-one name reference. Where is this value set? It looks like it takes the referenced table class name, and just makes the first character lowercase. But if it’s not many-to-one, it will take the name of the column, or use the proprty set in the generate wizard – which is what I’m trying to do for many-to-one. Is this possible with the templates? Am I missing something?
Thanks,
Dan
dapriettMemberHi – I was wondering if someone could post a list of just the new hibernate functions in 4.1.1 and maybe a brief description of what each function does. Or if this is already posted already, please send the link. I already read the new and noteworthy section but I was hoping for something more specific. I couldn’t find the updated documentation.
Also, do you know if this feature has been added:
@dapriett wrote:
Is there a way to tell myeclipse to use the name of the column, not the table class it references, as a base for the naming of foreign keys? For example, here’s a table of companies, which has a foreign key to itself for a parent company.
<u>Company</u>
Company_Id
Company_Name
Company_Address
Parent_Company_idI would prefer it named that foreign key reference as parentCompany intead of just Company – it would be less confusing.
Haris PecoMemberDan,
4.1.1 fix a lot bugs and this is some new features:
– generate POJO from hbm (right click on *hbm.xml)
– generate version and timestamp in RE eng (wizard Page 2)
– include referencing tables (for example, when you select Employees MyEclipse can add Departments and other exported or imported keys automatic) – this is my favorite (MyEclipse add all relations for selected tables)
– specify className for table (this is partially solution for your request, but for complete request we will add features ‘inject reverse naming strategy’)Last 2 features are from wizard’s Page 3
Best
-
AuthorPosts