我正在开发一个门户项目,我不得不使用WebSphere Portal,Spring portlet MVC和Hibernate.我没有很多配置Spring和Hibernate的经验,因此非常感谢各种帮助.
我在WebSphere 7.0.0.25(安装了Portal 6.1)上创建了一个JDBC数据源,其中JNDI名称为jdbc/eshop.然后我指定了JAAS身份验证别名并将其设置为容器管理的身份验证别名.测试连接尝试成功,所以我猜数据源的配置是合适的.我的下一步是在web.xml中进行资源引用:
<resource-ref>
<description>DB Connection</description>
<res-ref-name>eshop</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Run Code Online (Sandbox Code Playgroud)
要将res-ref-name绑定到ibm-web-bnd中的实际JNDI名称,我添加了以下行:
<resource-ref name="eshop" binding-name="java:comp/env/jdbc/eshop" />
Run Code Online (Sandbox Code Playgroud)
现在我的Hibernate实体:
@Entity
@Table(name = "HIBERNATE_TEST", schema = "SCHEME_NAME")
public class HibernateTest implements java.io.Serializable {
private short id;
private String text;
public HibernateTest() {
}
public HibernateTest(String text) {
this.text = text;
}
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name = "ID")
public short getId() {
return this.id;
}
public void setId(short id) {
this.id = id;
}
@Column(name = "TEXT", nullable = false, length = …Run Code Online (Sandbox Code Playgroud)