HibernateDomainExporter and inheritance with composite-id #1459

Closed
vveloso opened this Issue Jul 28, 2015 · 0 comments

Projects

None yet

2 participants

@vveloso
Contributor
vveloso commented Jul 28, 2015

With QueryDSL 3.6.5, the following XML mappings generate public final fields that are not initialized in leaf types.

<hibernate-mapping default-access="field" default-lazy="false">
 <class abstract="true"
  name="ConnectionRouteDb" table="DCN_NE_ROUTES">
  <composite-id access="field" name="routeKey" class="ConnectionRouteDbKey">
   <key-property name="type" type="string" column="ROUTE_TYPE"/>
   <key-property name="key" type="string" column="ROUTE_KEY"/>
  </composite-id>
  <discriminator force="false" insert="false" not-null="true">
   <column name="ROUTE_TYPE"/>
  </discriminator>
  <version access="field" column="VERSION" generated="never"
   name="version" type="int"/>
  <property access="field" generated="never" lazy="false" name="cost" type="int">
   <column name="COST"/>
  </property>
  <property access="field" generated="never" lazy="false" name="neId" type="int">
   <column name="NE_ID"/>
  </property>
 </class>
</hibernate-mapping>
<hibernate-mapping>
 <subclass discriminator-value="GATEWAY"
  extends="ConnectionRouteDb" lazy="false"
  name="GatewayRouteDb" select-before-update="false">
 </subclass>
</hibernate-mapping>

Generates:

@Generated("com.mysema.query.codegen.EntitySerializer")
public class QNeConnectionRouteDb extends EntityPathBase<NeConnectionRouteDb<?, ?>> {

    private static final long serialVersionUID = -2050193206L;

    private static final PathInits INITS = PathInits.DIRECT2;

    public static final QNeConnectionRouteDb neConnectionRouteDb = new QNeConnectionRouteDb("neConnectionRouteDb");

    public final com.ossnms.bicnet.emne.core.entities.ne.data.QNeConnectionRouteData_NeConnectionRoutePrototype _super = new com.ossnms.bicnet.emne.core.entities.ne.data.QNeConnectionRouteData_NeConnectionRoutePrototype(this);

    public final NumberPath<Integer> cost = createNumber("cost", Integer.class);

    public final NumberPath<Integer> neId = createNumber("neId", Integer.class);

    public final QNeConnectionRouteDbKey routeKey;

    public final NumberPath<Integer> version = createNumber("version", Integer.class);

    @SuppressWarnings("all")
    public QNeConnectionRouteDb(String variable) {
        this((Class)NeConnectionRouteDb.class, forVariable(variable), INITS);
    }

    @SuppressWarnings("all")
    public QNeConnectionRouteDb(Path<? extends NeConnectionRouteDb> path) {
        this((Class)path.getType(), path.getMetadata(), path.getMetadata().isRoot() ? INITS : PathInits.DEFAULT);
    }

    public QNeConnectionRouteDb(PathMetadata<?> metadata) {
        this(metadata, metadata.isRoot() ? INITS : PathInits.DEFAULT);
    }

    @SuppressWarnings("all")
    public QNeConnectionRouteDb(PathMetadata<?> metadata, PathInits inits) {
        this((Class)NeConnectionRouteDb.class, metadata, inits);
    }

    public QNeConnectionRouteDb(Class<? extends NeConnectionRouteDb<?, ?>> type, PathMetadata<?> metadata, PathInits inits) {
        super(type, metadata, inits);
        this.routeKey = inits.isInitialized("routeKey") ? new QNeConnectionRouteDbKey(forProperty("routeKey")) : null;
    }

}
@Generated("com.mysema.query.codegen.EntitySerializer")
public class QNeGatewayRouteDb extends EntityPathBase<NeGatewayRouteDb> {

    private static final long serialVersionUID = 169698434L;

    public static final QNeGatewayRouteDb neGatewayRouteDb = new QNeGatewayRouteDb("neGatewayRouteDb");

    public final QNeConnectionRouteDb _super;

    //inherited
    public final NumberPath<Integer> cost;

    //inherited
    public final NumberPath<Integer> neId;

    // custom
    public final QNeConnectionRouteDbKey routeKey = new QNeConnectionRouteDbKey(forProperty("routeKey"));

    //inherited
    public final NumberPath<Integer> version;

    public QNeGatewayRouteDb(String variable) {
        super(NeGatewayRouteDb.class, forVariable(variable));
    }

    public QNeGatewayRouteDb(Path<? extends NeGatewayRouteDb> path) {
        super(path.getType(), path.getMetadata());
    }

    public QNeGatewayRouteDb(PathMetadata<?> metadata) {
        super(NeGatewayRouteDb.class, metadata);
    }

}

Which does not compile.

The same issue happens on 3.6.3. I did not test 3.6.4.

If the key is simple instead of composite, the code is generated correctly. Unfortunately I need to use composite keys.

@timowest timowest added the progress label Aug 3, 2015
@timowest timowest added this to the 4.0.4 milestone Aug 31, 2015
@timowest timowest removed the progress label Aug 31, 2015
@timowest timowest closed this Aug 31, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment