Mod4j: Modeling for Java using Domain Specific Languages

Incorrect Hibernate mapping generated when creating an association from a class to itself

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 1.0.1
  • Fix Version/s: 1.1.0
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    0

Description

From the mailgroup:

Say I have a Vacancy which can be related to another Vacancy.

Given a class

class Vacancy [ .... ]

and an association:

association Vacancy vacancy many -> many Vacancy relatedVacancies;

the following Hibernate mapping is generated:

<class name="Vacancy" optimistic-lock="version" table="Vacancy_TABLE">
        <cache usage="read-write"/>
        <id column="id" name="id" type="java.lang.Long">
            <generator class="native"/>
        </id>

        ...........

        <set name="relatedVacancies" table="Vacancy_Vacancy">
            <key column="Vacancy_ID" not-null="true"/>
            <many-to-many class="Vacancy" column="Vacancy_ID"/>
        </set>
</class>

Since the column "Vacancy_ID" is used twice in this definition, you would need a table "Vacancy_Vacancy" with two "Vacancy_ID" columns which is kinda impossible. I can probably workaround this by introducing a RelatedVacancy domain object, but I'd rather not

Activity

Hide
Vincent Lussenburg added a comment -

I'm currently using the workaround:

class VacancyRelation [
]

association Vacancy vacature one <-> many VacatureRelatie vacancyRelations;
association VacancyRelations vacancyRelations many -> one Vacancy relatedVacancy;

But empty business classes causes an in issue in the data contract.

Show
Vincent Lussenburg added a comment - I'm currently using the workaround:
class VacancyRelation [
]

association Vacancy vacature one <-> many VacatureRelatie vacancyRelations;
association VacancyRelations vacancyRelations many -> one Vacancy relatedVacancy;
But empty business classes causes an in issue in the data contract.
Hide
Eric Jan Malotaux added a comment -

See commit-message for delta 2419.

Show
Eric Jan Malotaux added a comment - See commit-message for delta 2419.
Hide
Johan Vogelzang added a comment -

Eric Jan,

Please check if this issue is also fixed in trunk. If so, this issue can be closed.

Show
Johan Vogelzang added a comment - Eric Jan, Please check if this issue is also fixed in trunk. If so, this issue can be closed.
Hide
Eric Jan Malotaux added a comment -

This fix was merged to the trunk.

Show
Eric Jan Malotaux added a comment - This fix was merged to the trunk.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: