This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 223543 - "Hibernate Mapping Files and POJOs from Database"-Wizard does not generate any relationship-mappings in hbm.xml nor entity classes
Summary: "Hibernate Mapping Files and POJOs from Database"-Wizard does not generate an...
Status: NEW
Alias: None
Product: javaee
Classification: Unclassified
Component: Hibernate (show other bugs)
Version: 7.1
Hardware: All All
: P2 normal (vote)
Assignee: Sergey Petrov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-09 08:41 UTC by markiewb
Modified: 2016-06-12 00:54 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Shows the error and the expectations as comments (326.83 KB, image/png)
2012-12-09 08:42 UTC, markiewb
Details

Note You need to log in before you can comment on or make changes to this bug.
Description markiewb 2012-12-09 08:41:25 UTC
[ BUILD # : 201212080001 ]
[ JDK VERSION : 1.7.0_09 ]

I am currently testing http://wiki.netbeans.org/TS_71_HibernateSupport 
using the default sample-Derby/Java-DB.

The "Test suite: Hibernate Wizards > 4. Create POJOs from database" fails. 
Expected is that "HBM files should be generated for every table (e.g. 
Customer.hbm.xml). Those files should contain property mapping as well as 
relationship mappings." 

Steps for reproduction (in short - more steps see testcase link above):
* connect to standard sample Derby DB
* generate hibernate.cfg.xml and hibernate.reveng.xml
* "File New > New Hibernate Mapping Files and POJOs from  Database"
** check "JDK5-Features", "EJB3-Annotations", "Generate Domain code", 
"Generate Hibernate XML Mappings"
** click 'finish'

ACTUAL: 
* relationship mappings (like many-to-one/one-to-one) are NOT generated 
into the *.hbm.xml 
* relationship mappings (like @OneToOne,@OneToMany) are NOT 
generated into the *.java Entities 
(* generated entities do not contain any JDK5-Feature like generics for 
@OneToMany-Relations f.e. "List<Product> getProducts()" - IMHO missing 
because of previous error)
* also see the attached screenshot 

EXPECTED: 
* relationship mappings (like many-to-one/one-to-one) are generated into 
the *.hbm.xml 
* relationship mappings (like @OneToOne,@OneToMany) are generated 
into the *.java Entities 
(* generated entities contain generics for @OneToMany-Relations f.e. 
"List<Product> getProducts()")
---
Product Version: NetBeans IDE Dev (Build 201212080001)
Java: 1.7.0_09; Java HotSpot(TM) 64-Bit Server VM 23.5-b02
Runtime: Java(TM) SE Runtime Environment 1.7.0_09-b05
System: Windows 7 version 6.1 running on amd64; Cp1252; de_DE (nb)
Comment 1 markiewb 2012-12-09 08:42:17 UTC
Created attachment 129097 [details]
Shows the error and the expectations as comments
Comment 2 Sergey Petrov 2012-12-10 18:52:29 UTC
I'm not sure it was expected to work, current POJOs represent tables without any relationships information, even if ejb3/java5 options are not selected. yes, it's specified in test spec and I may need to try if it used to work at least in 7.1.
Comment 3 markiewb 2012-12-10 19:31:31 UTC
(In reply to comment #2)
> I'm not sure it was expected to work, current POJOs represent tables without
> any relationships information, even if ejb3/java5 options are not selected.
> yes, it's specified in test spec and I may need to try if it used to work at
> least in 7.1.

What is the Java 5 options for? I expected generics-stuff like "List<Product> getProducts()" but this induces the modelling of relationships...
Comment 4 Sergey Petrov 2012-12-10 19:55:02 UTC
from help
JDK 5 Language Features. When selected the generated code will take advantage of Java language features such as generics and static imports that are supported by JDK 5.
EJB 3 Annotations. When selected the generated POJOs use annotations for mapping information.

in case if there was any relationship without generics it should start to use generics, but as I see and it's tested in 7.1 also (spec version) it wasn't implemented. current behavior seems to be 'by design', as manufactorer isn't missed but is used as usual field. for example in jpa area it's one of generation options to use fields for fk if relationships is missed (in cas of hibernate it's permanent strategy)
Comment 5 Sergey Petrov 2012-12-12 10:46:28 UTC
I afraid it need to be resolved either as won't fix or as enhancement as it works in some way now, and it was created this way and seems to be the same always(as far as I can see from investigation since 7.1) and support level for the area may not be enough to implement in this/next release, but this really looks like a missed feature.
Comment 6 mannan4net 2016-03-14 08:10:09 UTC
I am an old user of netbeans and i did the book author example in which the relationship was generating properly using Oracle DB.

But Now I need to work again with hibernate using Derby db, the relationship in pojo are not generated.

I did perform with some other schema as well and it was working perfectly fine, I am not sure if it is due to change of the database from oracle to derby or change in netbeans version, currently I am using 6.9.1, 7.2 , and 8 but no luck.

What I am missing I am not sure, someone might guide me.
Comment 7 KevinAnderson 2016-06-12 00:54:48 UTC
My experience is similar to mannan4net@netbeans.org's.  I'm using NetBeans 8.1 and the wizard appears to work perfectly on the MySQL sakila example database.   But with the Derby sample database, no relationships get generated.  

What's more, I can't even seem to force the issue.  I tried adding this
<table> tag to my .reveng.xml:

    <table name="PURCHASE_ORDER">
        <foreign-key foreign-table="CUSTOMER" constraint-name="FK_PO_CUST">
            <column-ref foreign-column="CUSTOMER_ID" local-column="CUSTOMER_ID"/>
            <many-to-one property="customerId"/>
        </foreign-key>
    </table>

The wizard ignored it completely, giving no error messages and generating the same PurchaseOrder.java and PurchaseOrder.hbm.xml as when the tag wasn't there.