Jpa querydsl实例变量
从中,我找不到querydsl生成的默认实例变量和自定义变量之间的差异 对于定义为的实体客户Jpa querydsl实例变量,jpa,querydsl,Jpa,Querydsl,从中,我找不到querydsl生成的默认实例变量和自定义变量之间的差异 对于定义为的实体客户 @Entity public class Customer { private String firstName; private String lastName; public String getFirstName(){ return firstName; } public String getLastName(){ ret
@Entity
public class Customer {
private String firstName;
private String lastName;
public String getFirstName(){
return firstName;
}
public String getLastName(){
return lastName;
}
public void setFirstName(String fn){
firstName = fn;
}
public void setLastName(String ln)[
lastName = ln;
}
}
使用默认实例变量和自定义变量的区别是什么
QCustomer customer = QCustomer.customer;
VS
在第二种情况下,自定义变量的可能使用情形是什么?在序列化过程中,变量名也是这样使用的。如果需要在查询中引用同一类型的多个实例,则需要使用多个变量 这里有一个例子
QCustomer customer = QCustomer.customer;
QCustomer customer2 = new QCustomer("customer2");
List<Customer> customers = query.from(customer)
.where(new JPASubQuery()
.from(customer2)
.where(customer2.id.ne(customer.id),
customer2.lastName.eq(customer.lastName),
customer2.firstName.eq(customer.firstName))
.exists())
.list(customer);
QCustomer-customer=QCustomer.customer;
QCCustomer customer2=新的QCCustomer(“customer2”);
列出客户=query.from(客户)
.where(新JPASubQuery()
.发件人(客户2)
.其中(customer2.id.ne(customer.id),
customer2.lastName.eq(customer.lastName),
customer2.firstName.eq(customer.firstName))
.exists())
.名单(客户);
如果在只有一个QCustomer实例要使用的所有查询中使用默认变量,可以吗?@TheKojuEffect:可以,这将是它们的预期用途。
QCustomer customer = QCustomer.customer;
QCustomer customer2 = new QCustomer("customer2");
List<Customer> customers = query.from(customer)
.where(new JPASubQuery()
.from(customer2)
.where(customer2.id.ne(customer.id),
customer2.lastName.eq(customer.lastName),
customer2.firstName.eq(customer.firstName))
.exists())
.list(customer);