We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 9 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
这些库取决于您可能想要实现的功能。
如果您使用 Maven,这些应该会给您一个良好的开始。
c3p0 用于 postgres 连接上的连接池。
我强烈建议采用 hibernate 注释方法(正如您通过 maven 添加的注释包所看到的那样)。
因此,要使用 postgresql db + hibernate,请将以下内容添加到您的 applicationContext:
您在这里基本上所做的是使用 jdbc.properties 文件配置 jdbc 连接(您需要制作一个 - 如果您需要帮助,请给我最重要的是jdbc驱动程序,即org.postgresql.Driver)。然后,您将这些属性连接到 c3p0 连接池中,并将其传递给 AnnotationSessionfactory。
要在应用程序中使用此 sessionFactory,您可以在 Dao 类中扩展 HibernateDaoSupport(HibernateDaoSupport 随 Spring 一起提供,基本上为您进行事务管理),然后在 sessionFactory 参数上注入 sessionFactory。但是,建议不要再使用 HibernateDaoSupport,而是使用 @Repository Annotation - 在 google 上检查一下。
我希望这能给你一些开始的东西。您可以随时通过谷歌搜索更多教程,例如 http://www.vaannila .com/hibernate/hibernate-example/hibernate-annotations-1.html
干杯
The libraries depend on the functionalities you may want to implement.
If you're using maven, these should give you a good start to work with.
c3p0 is for connection pooling on your postgres connection.
I'd strongly advise to go for the hibernate annotation approach (as you can see by the annotation packages added via maven).
So to make use of your postgresql db + hibernate, add the following to your applicationContext:
What you basically did here was to configure the jdbc connection using a jdbc.properties file (you need to make one - if you need help with it, gimme a comment. Most important thing is the jdbc driver, which is org.postgresql.Driver). Then you wired these properties into a c3p0 connection pool and pass this to a AnnotationSessionfactory.
To use this sessionfactory in your application, you could extend the HibernateDaoSupport in your Dao class (the HibernateDaoSupport comes with Spring and basically does the transaction management for you) and there inject the sessionfactory on the sessionFactory parameter. However, it is advised to not use the HibernateDaoSupport any longer, but instead go for the @Repository Annotation - check that on google.
I hope this gives you something to start with. You could always google for further tutorials like http://www.vaannila.com/hibernate/hibernate-example/hibernate-annotations-1.html
cheers