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.

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

I have added this to my config file but it does not seem to work for me, though I'm generating from PostgreSql DB.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.