我刚刚用activator和playJava创建了一个新项目。
我的build.sbt:
import play.sbt.PlayImport._
name := """querdsl"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayJava,QueryDSLPlugin)
queryDSLPackage := "models"
scalaVersion := "2.11.6"
libraryDependencies ++= Seq(
javaJdbc,
cache,
javaWs,
javaJpa,
"org.hibernate" % "hibernate-entitymanager" % "4.3.10.Final"
)
routesGenerator := InjectedRoutesGenerator
我的plugins.sbt:
// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.2")
// Web plugins
addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.0.6")
addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.3")
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7")
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0")
addSbtPlugin("com.code-troopers.play" % "play-querydsl" % "0.1.2")
我只创建了一个模型:
package models;
import enums.Status;
import javax.persistence.*;
@Entity
@Table(name="User")
public class User {
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID")
@Id
private Integer id;
@Column(name = "Lastname", nullable = false)
private String lastname;
@Column(name = "Firstname", nullable = false)
private String firstname;
@Column(name = "Status", nullable = false)
@Enumerated(EnumType.STRING)
private Status status;
}
和枚举:
package enums;
public enum Status {
UP,
DOWN
}
生成的Quser:
package models;
import static com.mysema.query.types.PathMetadataFactory.*;
import com.mysema.query.types.path.*;
import com.mysema.query.types.PathMetadata;
import javax.annotation.Generated;
import com.mysema.query.types.Path;
/**
* QUser is a Querydsl query type for User
*/
@Generated("com.mysema.query.codegen.EntitySerializer")
public class QUser extends EntityPathBase<User> {
private static final long serialVersionUID = 1339629807L;
public static final QUser user = new QUser("user");
public final StringPath firstname = createString("firstname");
public final NumberPath<Integer> id = createNumber("id", Integer.class);
public final StringPath lastname = createString("lastname");
public final NumberPath<Status> status = createNumber("status", Status.class);
public QUser(String variable) {
super(User.class, forVariable(variable));
}
public QUser(Path<? extends User> path) {
super(path.getType(), path.getMetadata());
}
public QUser(PathMetadata<?> metadata) {
super(User.class, metadata);
}
}
我们可以看到字段状态生成错误应该是: public final EnumPath status = createEnum(“status”,enums.Status.class);
任何想法为什么enum被转换为numberPath而不是enumPath?
感谢您的回答。