Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Hibernate xml codegeneration #210

Closed
ghost opened this issue Aug 7, 2012 · 8 comments
Closed

Problem with Hibernate xml codegeneration #210

ghost opened this issue Aug 7, 2012 · 8 comments

Comments

@ghost
Copy link

ghost commented Aug 7, 2012

Hi there

As written in https://groups.google.com/forum/#!topic/querydsl/_uUy9vrblrg this is a new bug report.

With QueryDSL 2.7.0, the Hibernate to XML code generator generates not compileable sources.

he problem is the following mapping in customer.hbm.xml:

    <set name="contacts" cascade="all-delete-orphan" order-by="value" fetch="join">
        <key column="customer_id"/>
        <one-to-many class="CustomerContact"/>
    </set>

This is generated in QCustomer.java as

public final SetPath<Contact, Path> contacts = this.<Contact, Path>createSet("contacts", Contact.class, Path.class);

This is leading to compiler errors, as the Path class does not extend the SimpleExpression class, it is just an interface. What about the following:

public final SetPath<Contact, SimplePath> contacts = this.<Contact, SimplePath>createSet("contacts", Contact.class, SimplePath.class);

Regards
Mirko

@timowest
Copy link
Member

timowest commented Aug 8, 2012

Could you post the sources of Customer, Contact and CustomerContact? I need probably also the mapping parts of these classes to be able to reproduce the problem.

@mirkosertic
Copy link

Hi there

Here are the sources:

Customer.java

public class Customer extends Person<CustomerContact, CustomerHistory> implements UDFSupport {

private Map<String, UserDefinedField> udf = new HashMap<String, UserDefinedField>();

public Customer() {
}

public Map<String, UserDefinedField> getUdf() {
    return udf;
}

public void setUdf(Map<String, UserDefinedField> udf) {
    this.udf = udf;
}

}

Person.java

public class Person<T extends Contact, H extends HistoryEntity> extends
AuditableEntity {

private String titel;

private String name1;

private String name2;

private String company;

private String street;

private String country;

private String plz;

private String city;

private String nationalitaet;

private String geburtsdatum;

private String comments;

private boolean contactforbidden;

private Set<T> contacts = new HashSet<T>();

private Set<H> history = new HashSet<H>();

private String kreditorNr;

private String debitorNr;

public Person() {
}

public String getCity() {
    return city;
}

public void setCity(String city) {
    this.city = city;
}

public String getComments() {
    return comments;
}

public void setComments(String comments) {
    this.comments = comments;
}

public String getCompany() {
    return company;
}

public void setCompany(String company) {
    this.company = company;
}

public boolean isContactforbidden() {
    return contactforbidden;
}

public void setContactforbidden(boolean contactforbidden) {
    this.contactforbidden = contactforbidden;
}

public String getCountry() {
    return country;
}

public void setCountry(String country) {
    this.country = country;
}

public Set<T> getContacts() {
    return contacts;
}

public void setContacts(Set<T> kontakte) {
    this.contacts = kontakte;
}

public String getName1() {
    return name1;
}

public void setName1(String name1) {
    this.name1 = name1;
}

public String getName2() {
    return name2;
}

public void setName2(String name2) {
    this.name2 = name2;
}

public String getPlz() {
    return plz;
}

public void setPlz(String plz) {
    this.plz = plz;
}

public String getStreet() {
    return street;
}

public void setStreet(String street) {
    this.street = street;
}

public Set<H> getHistory() {
    return history;
}

public void setHistory(Set<H> history) {
    this.history = history;
}

public String getKreditorNr() {
    return kreditorNr;
}

public void setKreditorNr(String kreditorNr) {
    this.kreditorNr = kreditorNr;
}

public String getDebitorNr() {
    return debitorNr;
}

public void setDebitorNr(String debitorNr) {
    this.debitorNr = debitorNr;
}

public String getTitel() {
    return titel;
}

/**
 * @param titel the titel to set
 */
public void setTitel(String titel) {
    this.titel = titel;
}

public String getNationalitaet() {
    return nationalitaet;
}

public void setNationalitaet(String nationalitaet) {
    this.nationalitaet = nationalitaet;
}

public String getGeburtsdatum() {
    return geburtsdatum;
}

public void setGeburtsdatum(String geburtsdatum) {
    this.geburtsdatum = geburtsdatum;
}

public List<T> getEMailContacts() {
    List<T> theResult = new ArrayList<T>();
    for (T theEntry : getContacts()) {
        if (theEntry.getType().isEmail()) {
            theResult.add(theEntry);
        }
    }
    return theResult;
}

public List<T> getWebContacts() {
    List<T> theResult = new ArrayList<T>();
    for (T theEntry : getContacts()) {
        if (theEntry.getType().isWeb()) {
            theResult.add(theEntry);
        }
    }
    return theResult;
}

}

CustomerContact.java

public class CustomerContact extends Contact {
}

Contact.java

public abstract class Contact extends AuditableEntity {

private String value;

private ContactType type;

public String getValue() {
    return value;
}

public void setValue(String value) {
    this.value = value;
}

public ContactType getType() {
    return type;
}

public void setType(ContactType type) {
    this.type = type;
}

}

Mapping file Customer.hbm.xml

    <id name="id" column="id">
        <generator class="identity"/>
    </id>

    <property column="creationDate" name="creationDate"/>
    <property column="creationUser" name="creationUserID"/>
    <property column="changedDate" name="lastModificationDate"/>
    <property column="changedUser" name="lastModificationUserID"/>

    <property name="name1"/>
    <property name="name2" />
    <property name="company"/>
    <property name="street"/>
    <property name="country"/>
    <property name="plz"/>
    <property name="city"/>
    <property name="comments" type="text"/>
    <property name="contactforbidden"/>

    <property name="debitorNr"/>
    <property name="kreditorNr"/>

    <property name="titel"/>
    <property name="nationalitaet"/>
    <property name="geburtsdatum"/>     

    <set name="contacts" cascade="all-delete-orphan" order-by="value" fetch="join">
        <key column="customer_id"/>
        <one-to-many class="CustomerContact"/>
    </set>

    <set name="history" cascade="all-delete-orphan" order-by="creationDate DESC" fetch="select" lazy="true">
        <key column="customer_id"/>
        <one-to-many class="CustomerHistory"/>
    </set>

CustomerContact.hbm.xml

    <id name="id" column="id">
        <generator class="identity"/>
    </id>

    <property column="creationDate" name="creationDate"/>
    <property column="creationUser" name="creationUserID"/>
    <property column="changedDate" name="lastModificationDate"/>
    <property column="changedUser" name="lastModificationUserID"/>

    <property name="value"/>

    <many-to-one name="type" class="ContactType">
        <column name="type_id"/>
    </many-to-one>

I checked every Version from 2.5 to 2.7. The problem can be reproduced with every version.

@timowest
Copy link
Member

timowest commented Aug 9, 2012

I need all the mapping files for the files you provide. Also there seem to be some type parameters for Person missing.

Looks like incomplete mapping information, but I really need more data to provide a definite answer.

@mirkosertic
Copy link

Hi there

The sources and mapping files can be downloaded here:

http://mogwai.svn.sourceforge.net/viewvc/mogwai/trunk/mogwai/jee-ddd/

See the domain maven module for java classes, the infrastructure module for mapping files. You can compile it out of the box using mvn clean to reproduce the problem.

Regards
Mirko

@timowest
Copy link
Member

Could you point me directly to the HBM files and post the error you get when building mogwai? I couldn't find Hibernate mapping files in the infrastructure project and the build succeeded.

@timowest
Copy link
Member

Any progress on this issue from your side?

@mirkosertic
Copy link

Please check again, i forgot to commit some stuff.. Just run mvn clean compile on the parent pom.

@timowest
Copy link
Member

Released in 2.7.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants