Hello,
Problem with codi(1.0.5) Transactions and Java (1.6/1.7) generics.
Infrastructure:
Myfaces12
Jpa2 (eclipslink 2.4)
Codi 1.0.5
Tomcat 7
OpenWebBeans 1
See Classes below
Problem is:
When we inject the Interface IpersonDao in the Service Class (PersonServerImpl)
and do the following:
dao.delete(person) à No Transaction is openend and nothing happens!!!!!
doa.persist(person)à Transaction is opened and entity is saved.
Difference is that in the IpersonDaoSuperInterface the delete function contains
generic arguments and the persist fuction has a concrete Object (person). But
we need the generic type for all function in the IpersonDaoSuperInterface.
When we inject the Concrete Implementation of the dao ( @Inject private
PersonDao dao) in PersonServerImpl the delete function also works.
Question.
Why cant we inject the Dao Interface when we use java generics in the interface
hierarchy???
Service Class:
public class PersonServerImpl implements PersonService
{
@Inject
private IPersonDao dao;
public void removePerson(Person person)
{
dao.delete(person);
}
public Person savePerson(Person person)
{
return dao.persist(person);
}
}
Dao Class:
public class PersonDao implements IPersonDao
{
@Transactional
public void delete(Person entity)
{
em.remove(em.merge(entity));
}
@Transactional
public Person persist(Person entity)
{
em.persist(entity);
return entity;
}
...
}
IpersonDao Interface:
public interface IPersonDao extends IpersonDaoSuperInterface<Person>
{
public abstract List<Person> loadAll();
public abstract Person loadById(Serializable id);
public abstract List<Person> findByLastName(String lastname);
}
IpersonDaoSuperInterface:
public interface IpersonDaoSuperInterface<T extends DbObject>
{
public abstract void delete(T entity);
public abstract Person persist(Person entity);
public abstract T update(T entity);
}
Thanks fore help
steffen