Created
February 17, 2014 09:00
-
-
Save yanhua365/9047130 to your computer and use it in GitHub Desktop.
Hibernate里使用Spring JdbcTemplate的代码。来自appfuse的UserDaoHibernate。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String getUserPassword(Long userId) { | |
JdbcTemplate jdbcTemplate = | |
new JdbcTemplate(SessionFactoryUtils.getDataSource(getSessionFactory())); | |
Table table = AnnotationUtils.findAnnotation(User.class, Table.class); | |
return jdbcTemplate.queryForObject( | |
"select password from " + table.name() + " where id=?", String.class, userId); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment