嵌入式

时间:2017-11-09 20:26:07

标签: java hibernate spring-boot

问题在于: 我想通过以下方法从数据库中撤回UserDomains列表:

@Query("SELECT dom FROM User usr JOIN usr.domains dom")
List<UserDomain> findDomains();     

这是我的实体和可嵌入的类:

@Entity
@Table(name = "users")
public class User {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "usr_id")
private Integer id;

@Column(name = "usr_username")
private String username;

@Column(name = "usr_password")
private String password;

@Column(name = "usr_email")
private String email;

@ElementCollection
@JoinTable(name = "user_domains", joinColumns = @JoinColumn(name = "udo_usr_id"))
private Set<UserDomain> domains;


@Embeddable
public class UserDomain {

@Column(name = "udo_dom_guid")
private String domGuid;

@Column(name = "udo_company_guid")
private String companyGuid;

问题是我在GET方法中尝试执行查询时遇到错误:

  

&#34;无法提取ResultSet; SQL [不适用];嵌套异常是org.hibernate.exception.SQLGrammarException:无法提取ResultSet&#34;

我一直试图解决这个问题好几个小时:(提前谢谢

0 个答案:

没有答案