Hibernate Metamodel Generator
JPA 2 定义了一个新的类型安全的标准API,可通过代码来定义标准查询,通过元模型来提供安全的类型处理。而 Hibernate Metamodel Generator 就是基于这个标准的一个实现。
示例代码:
@Entity
public class Order {
@Id
@GeneratedValue
Integer id;
@ManyToOne
Customer customer;
@OneToMany
Set<Item> items;
BigDecimal totalCost;
// standard setter/getter methods
}
@StaticMetamodel(Order.class)
public class Order_ {
public static volatile SingularAttribute<Order, Integer> id;
public static volatile SingularAttribute<Order, Customer> customer;
public static volatile SetAttribute<Order, Item> items;
public static volatile SingularAttribute<Order, BigDecimal> totalCost;
}
评论