我正在尝试使用带有连接的休眠查询语言在mySQL DB中找到Date列的最大值
@Query("select o.techid, CAST(MAX(o.last_modified) AS DATE) from com.dw.model.user.User as u left join com.dw.model.order.Order as o on u.username=o.techid group by o.techid") List<User> findUsers();
模型类别=
@Entity(name = "orders") @Scope("prototype") @Component @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class) public class Order { @Id private long orderNumber; private Date last_modified;
我收到此错误:-
由以下原因引起:java.lang.IllegalStateException:没有左侧的DOT节点!
有人可以告诉我如何用Hibernate编写此文件吗?
删除您的软件包名称。实体仅由其名称定义。点用于表之间的属性和链接(定义为@ ManyToOne *属性时)。
select o.techid, CAST(MAX(o.last_modified) AS DATE) from User as u left join Order as o on u.username=o.techid group by o.techid
编写HQL时,请考虑“类和属性”而不是“列”。