1
实体我有两个实体:JPA:与空属性没有检索
@Entity
@Table(name = "T_CLIENT")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Client implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "code")
private String code;
@Column(name = "nom")
private String nom;
@OneToOne
private TypeClient typeClient;
@Entity
@Table(name = "T_TYPECLIENT")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class TypeClient implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "nom")
private String nom;
我想这样做,查询:
@Query("Select id, nom, code, codeComptable, typeClient from Client")
List<Object[]> findAllWithoutForeignKey();
JPA与typeClient <>空只返回客户端。
如何获得所有客户?
谢谢。
它不起作用,Tomcat无法启动该查询服务器:引起:org.springframework.beans.factory.BeanCreationException:创建名为'clientRepository'的bean时出错:init方法的调用失败;嵌套异常是java.lang.IllegalArgumentException:对于方法的查询验证失败public abstract java.util.List com.myapp.repository.ClientRepository.findAllWithoutForeignKey()! – user1260928 2015-03-02 14:15:07
对不起,我编辑了我的答案。现在试试。 – 2015-03-02 14:29:37