Monday, April 24, 2017

Data Access Object (DAO)

# The Data Access Object (DAO) support in Spring is aimed at making it easy to
  work with data access technologies like JDBC,   Hibernate, JPA (our one JPA) or JDO in a consistent way

# The best way to guarantee that your Data Access Objects (DAOs) or
  repositories provide exception translation is to use the @Repository annotation

# Any DAO or repository implementation will need to access to a persistence resource,
 depending on the persistence technology used; for example, a JDBC-based repository will
 need access to a JDBC DataSource; a JPA - based repository will need access to an EntityManager.
 The easiest way to accomplish this is to have this resource dependency injected using one of
 the @Autowired,, @Inject,@Resource or @PersistenceContext annotations.

 @Autowired
 EntityManager em;

# return em.createNativeQuery(sql).getResultList();

# Query query = em.createNativeQuery(sql);
  BigDecimal exChangeRate = (BigDecimal)query.getSingleResult();

No comments:

Post a Comment

The AI Driven Software Developer, Optimize Innovate Transform

  The AI-Driven Software Developer: Optimize, Innovate, Transform": AI Transformation in Software Development : Understand how AI is re...