加载和加载有什么区别:
<dependency org="org.eclipse.persistence" name="eclipselink" rev="2.5.2"/>对比
<dependency org="org.eclipse.persistence" name="org.eclipse.persistence.jpa" rev="2.5.2"/>我可以看到,在maven " Eclipselink“中命名的EclipseLink具有比其他one...for示例目标数据库更多的类和实用程序:
org.eclipse.persistence.platform.database.oracle.OracleXXXPlatform
使用一种矿石的标准是什么?
谢谢你。
发布于 2018-10-30 06:34:19
这完全取决于您的需求的范围。在我的例子中,我使用了适合我的项目需要的EclipseLink。
JPQL的主要优点之一是,您可以在EclipseLink查询中直接调用原生函数。在Hibernate中,这不是直接可能的。
带有命名查询的实体类示例-
@Entity
@Table(name = "authorizedUsers", schema = "public")
@NamedQuery(name = "AuthorizedUsers.findByAll",
query = "SELECT a FROM AuthorizedUsers a where a.username = :username and a.password = :password")
public class AuthorizedUsers implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "id")
private Integer id;
@Column(name = "username")
private String username;
@Column(name = "password")
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
};然后设置查询参数,就像我们在上面的例子中所做的那样-
public List<AuthorizedUsers> findFragmentByAll(String username, String password)
throws PersistenceException, IllegalStateException {
if (em != null) {
final Query query = em.createNamedQuery("AuthorizedUsers.findByAll");
query.setParameter("username", username);
query.setParameter("password", password);
return query.getResultList();
}然而,em是实体管理器的一个实例。
https://stackoverflow.com/questions/33329533
复制相似问题