Hi,
I have added a simple relation from User to ControlePeso class, it´s a one
to Many relationship.
In User class:
private List controlePeso = new ArrayList();
@OneToMany(cascade=CascadeType.ALL, mappedBy="user")
public List getControlePeso()
{
return controlePeso;
}
In ControlePeso class:
@Entity
@Table(name="controle_peso")
public class ControlePeso extends BaseObject implements Serializable{
....
private User user;
@ManyToOne(optional=false)
@JoinColumn(name="user_id", updatable=false, nullable=false)
public User getUser()
{
return user;
}
I have used appfuse:gen with -Damp.genericCore=false option. Then I check
and all classes have been generated for ControlePeso(Manager, DAO, etc)
I hava also checked and found the entry added by appfuse:gen in
applicationContext.xml for ControlePesoDaoHibernate and ControlePesoManger
Then I have added a new entry in applicationContext-dao.xml for
ControlePesoDaoHibernate.
I than changed the ControlePesoDaoTest class to test a new method I want to
add to this(I´ve changed the sample-data.xml to get this results ok!!!):
public void testGetTodosDoUsuario(int idUser)
{
List lista = new ArrayList();
lista = controlePesoDao.getTodosDoUsuario(-1);
assertEquals(3, lista.size());
lista = controlePesoDao.getTodosDoUsuario(-2);
assertEquals(1, lista.size());
}
Finally I have added a new method in ControlePesoDao:
public List getTodosDoUsuario(int idUser);
and ControlePesoDaoHibernate:
public List getTodosDoUsuario(int idUser) {
List controlePesoList = getHibernateTemplate().find("from
ControlePeso
where user.id=?", idUser);
return controlePesoList;
}
After all this, when I try to run the dao layer test using:
mvn test -Dtest=*DaoTest
I get the following error(taken from surefire reports):
[D:\workspaces\projetos\controlepeso\target\test-classes\WEB-INF\applicationContext.xml]:
Cannot resolve reference to bean 'sessionFactory' while setting bean
property 'sessionFactory'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'sessionFactory' defined in class path resource
[applicationContext-dao.xml]: Invocation of init method failed; nested
exception is org.hibernate.AnnotationException: Use of @OneToMany or
@ManyToMany targeting an unmapped class:
br.com.maweb.controlepeso.model.User.controlePeso[br.com.maweb.controlepeso.model.ControlePeso]
I´m stuck on this for a couple of hours now and have no clue about what´s
causing this. I´ve checked every place I could think of where the problem
came, but no clue yet..
Any ideas will be appreciate.
tx in advance.
P.S - I have uploaded the surefire report if you need a complete stack
error.
http://www.nabble.com/file/p19860344/br.com.maweb.controlepeso.dao.UserDaoTest.txt
br.com.maweb.controlepeso.dao.UserDaoTest.txt
--
View this message in context:
http://www.nabble.com/OneToMany-Relation-Problem-from-User-tp19860344s2369p19860344.html
Sent from the AppFuse - User mailing list archive at Nabble.com.