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

HibernateDomainExporter and inheritance with composite-id #1459

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

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.

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