Hello,
I'm attempting to unit test my Hibernate DAOs and I haven't yet been
successful in connecting to the database and adding an entity, although
I believe I'm close to getting something successfully added. Currently
my test looks like this:
@Test
public void userTest() {
RegistryBuilder builder = new RegistryBuilder();
builder.add(DaoModule.class);
builder.add(HibernateCoreModule.class);
Registry reg = builder.build();
userDao = reg.getService(UserDao.class);
User user = createUser();
userDao.addUser(user);
}
and this is my DaoModule:
public class DaoModule {
public static UserDao buildUserDao
(@InjectService("HibernateSessionManager")
HibernateSessionManager sessionManager) {
UserDao userDao = new UserDao();
userDao.setSessionManager(sessionManager);
return userDao;
}
}
The problem I'm having is that when I attempt to persist a User object
via session.persist() I get the error:
org.hibernate.MappingException: Unknown entity:
com.mustardgrain.clientdailyupdate.entities.User
even though I'm using the import javax.persistence.Entity annotation. Am
I close to correctly testing here or am I barking up the wrong tree?
Thanks, Matthew
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org