2

I did this tutorial, and configured the Hibernate API and the mapping: https://netbeans.org/kb/docs/web/hibernate-webapp.html

(i'm using the JavaDB API with the 'sample' DB not MySQL)

But i have a problem: the generated hbm.xml files dont contain any foreign key mapping. (there are no one-to-many or many-to-one properties)

here is a sample class and mapping file. the RoleID should be a foreign key to the ROLE table ID field.

http://pastebin.com/tGnPTrXx

http://pastebin.com/bq4Q4RTi

im trying to edit the hibernate.reveng.xml file to force creating FK's - something like this:

<table name="USERS">
    <foreign-key constraint-name="ROLE_USER_FK" foreign-table="ROLE">
        <column-ref local-column="roleid" foreign-column="id" /> 
        <many-to-one property="roleid" />
    </foreign-key>
</table>

but it doesnt work.

spoulson
  • 21,335
  • 15
  • 77
  • 102
krstf
  • 627
  • 7
  • 25

1 Answers1

1

solved: hibernate.cfg.xml needed the hibernate.default_catalog and hibernate.default_schema property

krstf
  • 627
  • 7
  • 25
  • I have added this to my config file but it does not seem to work for me, though I'm generating from PostgreSql DB. – S.Serem Jan 31 '18 at 09:33