Generate from Hibernate .hbm.xml does not include primary key

Bug #660353 reported by Truong Xuan Tinh on 2010-10-14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fix Released

Bug Description

I have an model class as following:

public class Store implements Serializable {

 private static final long serialVersionUID = 7221730732392000227L;

 private String code;
 private String name;
 private String address;
 private String city;
 private String phoneDetails;
 private String faxDetails;
 private String zipCode;
 private String chainCode;
 private Area area;
 private State state;
 private Status status = Status.ACTIVE;

        // Getters and setters are omitted

And here is the mapping file for it:

<class name="xxx.model.Store" table="STORE">
        <cache usage="nonstrict-read-write"/>
        <id name="code" type="java.lang.String" column="CODE">
            <generator class="assigned"/>

        <property name="name">
            <column name="NAME"/>
        <property name="address">
            <column name="ADDRESS"/>
        <property name="city">
            <column name="CITY"/>
        <property name="phoneDetails">
            <column name="PHONE_DETAILS" length="30"/>
        <property name="faxDetails">
            <column name="FAX_DETAILS" length="30"/>
        <property name="zipCode">
            <column name="ZIP_CODE" length="15"/>
        <property name="chainCode">
            <column name="CHAIN_CODE"/>

        <many-to-one name="area" class="xxx.model.Area" column="AREA_CODE" not-null="false"/>
        <many-to-one name="state" class="xxx.model.State" column="STATE_CODE" not-null="false"/>

But the QStore object does not contain the 'code' property (which is the primary key of the Store).
I put the QStore code here for completeness.

import static com.mysema.query.types.PathMetadataFactory.*;

import com.mysema.query.types.*;
import com.mysema.query.types.path.*;

 * QStore is a Querydsl query type for Store
public class QStore extends EntityPathBase<Store> {

    private static final long serialVersionUID = -1753548466;

    private static final PathInits INITS = PathInits.DIRECT;

    public static final QStore store = new QStore("store");

    public final StringPath address = createString("address");

    public final QArea area;

    public final StringPath chainCode = createString("chainCode");

    public final StringPath city = createString("city");

    public final StringPath faxDetails = createString("faxDetails");

    public final StringPath name = createString("name");

    public final StringPath phoneDetails = createString("phoneDetails");

    public final QState state;

    public final StringPath zipCode = createString("zipCode");

    public QStore(String variable) {
        this(Store.class, forVariable(variable), INITS);

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

    public QStore(PathMetadata<?> metadata, PathInits inits) {
        this(Store.class, metadata, inits);

    public QStore(Class<? extends Store> type, PathMetadata<?> metadata, PathInits inits) {
        super(type, metadata, inits);
        this.area = inits.isInitialized("area") ? new QArea(forProperty("area")) : null;
        this.state = inits.isInitialized("state") ? new QState(forProperty("state")) : null;

Here is the code to generate Query Object:
public static void main(String[] args) {
  System.setProperty("env", "dev");

  System.out.println("Start generating query object......");
  String projectDir = System.getProperty("user.dir");
  System.out.println("projectDir:" + projectDir);

  String configDir = File.separator + projectDir + File.separator
    + "src" + File.separator + "main" + File.separator + "webapp"
    + File.separator + "WEB-INF" + File.separator;
  System.out.println("configDir:" + configDir);

  String genDir = projectDir + File.separator + "src" + File.separator
    + "main" + File.separator + "java" + File.separator;
  System.out.println("Generated dir:" + genDir);

  FileSystemXmlApplicationContext applicationContext = new FileSystemXmlApplicationContext(
    configDir + "applicationContext.xml", configDir
      + "dataSource.xml", configDir + "core.xml");
  LocalSessionFactoryBean sfFactoryBean = applicationContext
  Configuration configuration = sfFactoryBean.getConfiguration();
  HibernateDomainExporter domainExporter = new HibernateDomainExporter(
    "Q", new File(genDir), configuration);
  try {
  } catch (IOException e) {
   // TODO Auto-generated catch block

Thanks for the bug report. I fixed the identifier handling.

Changed in querydsl:
importance: Undecided → High
status: New → In Progress
Changed in querydsl:
status: In Progress → Fix Committed

Released in 2.0.3

Changed in querydsl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers