Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.springframework.orm.hibernate3.HibernateTemplate;
- @SuppressWarnings("unchecked")
- public List<Customer> getByNameCriteria(String firstName)
- {
- DetachedCriteria criteria = DetachedCriteria.forClass(Customer.class);
- criteria.add(Restrictions.eq("firstName", firstName));
- return (List<ReposTable>)hibernateTemplate.findByCriteria(criteria);
- }
- @SuppressWarnings("unchecked")
- public List<Customer> getByNameHSQL(String firstName)
- {
- return (List<Customer>) hibernateTemplate.findByNamedParam("from Customer t where t.firstName=:firstName","firstName",firstName);
- }
- List<Customer> allCustomers1 = rtRep.getByNameCriteria("John");
- List<Customer> allCustomers2 = rtRep.getByNameHSQL("John");
- @OneToMany(targetEntity=Address.class, fetch = FetchType.EAGER, mappedBy="customer" )
- @Cascade (value={CascadeType.SAVE_UPDATE })
- private Set<Address> addresses = new HashSet<Address>();
- criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
- @OneToMany(targetEntity=Address.class, fetch = FetchType.EAGER, mappedBy="customer" )
- @Cascade (value={CascadeType.SAVE_UPDATE })
- @Fetch(FetchMode.SELECT)
- private Set<Address> addresses = new HashSet<Address>();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement