Problem with Hibernate XML Mappings and composite-id's #256

Closed
mirkosertic opened this Issue Oct 22, 2012 · 5 comments

Comments

Projects
None yet
2 participants
@mirkosertic

The following xml mapping and class leads to

Embedded error: No property found for ch.bedag.gba.capitastra.datatransfer.bridge.mapping.RechtMapping.capiID
[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Cannot execute HibernateDomainExporter
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Cannot execute HibernateDomainExporter
at ch.bedag.gba.maven.plugin.querydsl.HibernateExportMojo.execute(HibernateExportMojo.java:64)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Caused by: java.lang.IllegalArgumentException: No property found for ch.bedag.gba.capitastra.datatransfer.bridge.mapping.RechtMapping.capiID
at com.mysema.query.jpa.codegen.HibernateDomainExporter.getType(HibernateDomainExporter.java:463)
at com.mysema.query.jpa.codegen.HibernateDomainExporter.handleProperty(HibernateDomainExporter.java:342)
at com.mysema.query.jpa.codegen.HibernateDomainExporter.collectTypes(HibernateDomainExporter.java:307)
at com.mysema.query.jpa.codegen.HibernateDomainExporter.execute(HibernateDomainExporter.java:232)

public abstract class D_SiCZuCapiRechtMapping {

    private MappingID id;

    public void setId(MappingID id) {
        this.id = id;
    }

    public int getSystemID() {
        return id.getSystemID();
    }

    public int getCapiPID() {
        return id.getCapiID();
    }
}
public class MappingID implements Serializable {

    private static final long serialVersionUID = -4623004134095871109L;
    private short systemID;

    private int capiID;

    public MappingID() {
        // Default-Konstruktor wird vom Hinernate Criteria-API verwendet
    }

    public MappingID(short systemID, int capiID) {
        this.capiID = capiID;
        this.systemID = systemID;
    }

    public short getSystemID() {
        return systemID;
    }

    public int getCapiID() {
        return capiID;
    }
}
<hibernate-mapping package="ch.bedag.gba.capitastra.datatransfer.bridge.mapping" default-access="field">

<class name="D_SiCZuCapiRechtMapping">

    <composite-id name="id" class="MappingID">
        <key-property name="capiID"/>
        <key-property name="systemID"/>
    </composite-id>     

// some properties stripped

</class>

</hibernate-mapping>

timowest added a commit that referenced this issue Oct 22, 2012

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Oct 22, 2012

Member

This example works well, but I assume your real case looks a bit different. How does ch.bedag.gba.capitastra.datatransfer.bridge.mapping.RechtMapping look like?

Member

timowest commented Oct 22, 2012

This example works well, but I assume your real case looks a bit different. How does ch.bedag.gba.capitastra.datatransfer.bridge.mapping.RechtMapping look like?

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Oct 22, 2012

Member

So either your Hibernate version handles composite properties differently or your example doesn't reflect your real case properly.

Member

timowest commented Oct 22, 2012

So either your Hibernate version handles composite properties differently or your example doesn't reflect your real case properly.

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Oct 24, 2012

Member

@mirkosertic Could you verify whether the issue is caused by a field/getter mismatch or something else?

Member

timowest commented Oct 24, 2012

@mirkosertic Could you verify whether the issue is caused by a field/getter mismatch or something else?

@mirkosertic

This comment has been minimized.

Show comment
Hide comment
@mirkosertic

mirkosertic Oct 26, 2012

Hi there

I checked of some getter or setter are missing, but they are correct.

I think the primary key property name discovery does not work properly, based on the described mapping the referenced property should be:

or ch.bedag.gba.capitastra.datatransfer.bridge.mapping.RechtMapping.id.capiID and not
or ch.bedag.gba.capitastra.datatransfer.bridge.mapping.RechtMapping.capiID

See the attached RechtMapping class for a complete example:

public class RechtMapping extends D_SiCZuCapiRechtMapping {
}

Hi there

I checked of some getter or setter are missing, but they are correct.

I think the primary key property name discovery does not work properly, based on the described mapping the referenced property should be:

or ch.bedag.gba.capitastra.datatransfer.bridge.mapping.RechtMapping.id.capiID and not
or ch.bedag.gba.capitastra.datatransfer.bridge.mapping.RechtMapping.capiID

See the attached RechtMapping class for a complete example:

public class RechtMapping extends D_SiCZuCapiRechtMapping {
}

timowest added a commit that referenced this issue Oct 26, 2012

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Oct 30, 2012

Member

Released in 2.8.2

Member

timowest commented Oct 30, 2012

Released in 2.8.2

@timowest timowest closed this Oct 30, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment