Some more on this: 

I can see in console when hibernate.cfg.xml is loaded , also I´ve
checked(again) and had the entry in this file:

<mapping class="br.com.maweb.controlepeso.model.ControlePeso"/>

so this is correct, right?

>From console the only weird things when I run the tests that I´m able to see
are:

2 hibernate loadings and a warning as follows: 

[WARNING] POM for 'org.hibernate:jtidy:pom:r8-20060801:runtime' is invalid.
It w
ill be ignored for artifact resolution. Reason: Parse error reading POM.
Reason:
 TEXT must be immediately followed by END_TAG and not START_TAG (position:
START
_TAG seen ...<licenses>\n\t\t\t<license>... @12:13)  for project
org.hibernate:j
tidy at
c:\tools\maven.repo\org\hibernate\jtidy\r8-20060801\jtidy-r8-20060801.po
m
[INFO] [hibernate3:hbm2ddl {execution: default}]
[INFO] Configuration XML file loaded:
file:/D:/workspaces/projetos/controlepeso/
src/main/resources/hibernate.cfg.xml
[INFO] Configuration XML file loaded:
file:/D:/workspaces/projetos/controlepeso/
src/main/resources/hibernate.cfg.xml

I´m sure the jtidy warning is not the problem. I´m concerned about 2
loadings for hibernate.cfg.xml file.

Still lost here, any help will be appreciated.. as I´m really worried about
carring on with appfuse on this project if I´m not able to use UnitTests....

Follows all the console copy for better understanding(you´ll find surefire
report atached in this same post in my first thread if you want to take a
look at it): 


D:\workspaces\projetos\controlepeso>mvn test -Dtest=*DaoTest
[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[INFO] Building AppFuse Struts 2 Application
[INFO]    task-segment: [test]
[INFO]
------------------------------------------------------------------------
[INFO] [aspectj:compile {execution: default}]
[INFO] [native2ascii:native2ascii {execution: native2ascii-utf8}]
[INFO] [native2ascii:native2ascii {execution: native2ascii-8859_1}]
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] Preparing hibernate3:hbm2ddl
[WARNING] Removing: hbm2ddl from forked lifecycle, to prevent recursive
invocation.
[INFO] [aspectj:compile {execution: default}]
[INFO] [native2ascii:native2ascii {execution: native2ascii-utf8}]
[INFO] [native2ascii:native2ascii {execution: native2ascii-8859_1}]
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[WARNING] POM for 'org.hibernate:jtidy:pom:r8-20060801:runtime' is invalid.
It will be ignored for artifact resolution.
Reason: Parse error reading POM. Reason: TEXT must be immediately followed
by END_TAG and not START_TAG (position: START
_TAG seen ...<licenses>\n\t\t\t<license>... @12:13)  for project
org.hibernate:jtidy at c:\tools\maven.repo\org\hibernat
e\jtidy\r8-20060801\jtidy-r8-20060801.pom
[INFO] [hibernate3:hbm2ddl {execution: default}]
[INFO] Configuration XML file loaded:
file:/D:/workspaces/projetos/controlepeso/src/main/resources/hibernate.cfg.xml
[INFO] Configuration XML file loaded:
file:/D:/workspaces/projetos/controlepeso/src/main/resources/hibernate.cfg.xml
[INFO] Configuration Properties file loaded:
D:\workspaces\projetos\controlepeso\target\classes\jdbc.properties
alter table controle_peso drop foreign key FK5243CE487452007B;
alter table user_role drop foreign key FK143BF46ACF273C9B;
alter table user_role drop foreign key FK143BF46A7452007B;
drop table if exists app_user;
drop table if exists controle_peso;
drop table if exists role;
drop table if exists user_role;
create table app_user (id bigint not null auto_increment, account_expired
bit not null, account_locked bit not null, add
ress varchar(150), city varchar(50), country varchar(100), postal_code
varchar(15), province varchar(100), cellphone_num
ber varchar(255), credentials_expired bit not null, email varchar(255) not
null unique, account_enabled bit, first_name
varchar(50) not null, last_name varchar(50) not null, password varchar(255)
not null, password_hint varchar(255), phone_
number varchar(255), username varchar(50) not null unique, version integer,
website varchar(255), primary key (id)) ENGI
NE=InnoDB;
create table controle_peso (id bigint not null auto_increment, data datetime
not null, peso float not null, user_id bigi
nt not null, primary key (id)) ENGINE=InnoDB;
create table role (id bigint not null auto_increment, description
varchar(64), name varchar(20), primary key (id)) ENGIN
E=InnoDB;
create table user_role (user_id bigint not null, role_id bigint not null,
primary key (user_id, role_id)) ENGINE=InnoDB;

alter table controle_peso add index FK5243CE487452007B (user_id), add
constraint FK5243CE487452007B foreign key (user_id
) references app_user (id);
alter table user_role add index FK143BF46ACF273C9B (role_id), add constraint
FK143BF46ACF273C9B foreign key (role_id) re
ferences role (id);
alter table user_role add index FK143BF46A7452007B (user_id), add constraint
FK143BF46A7452007B foreign key (user_id) re
ferences app_user (id);
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [dbunit:operation {execution: test-compile}]
[INFO] [surefire:test]
[INFO] Surefire report directory:
D:\workspaces\projetos\controlepeso\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running br.com.maweb.controlepeso.dao.UniversalDaoTest
INFO - AbstractSingleSpringContextTests.loadContextLocations(210) | Loading
context for locations: classpath:/applicatio
nContext-resources.xml,classpath:/applicationContext-dao.xml,classpath*:/applicationContext.xml,classpath:**/application
Context*.xml
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.61 sec <<<
FAILURE!
Running br.com.maweb.controlepeso.dao.LookupDaoTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.047 sec
<<< FAILURE!
Running br.com.maweb.controlepeso.dao.ControlePesoDaoTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.015 sec
<<< FAILURE!
Running br.com.maweb.controlepeso.dao.RoleDaoTest
Tests run: 5, Failures: 0, Errors: 5, Skipped: 0, Time elapsed: 0.063 sec
<<< FAILURE!
Running br.com.maweb.controlepeso.dao.UserDaoTest
Tests run: 8, Failures: 0, Errors: 8, Skipped: 0, Time elapsed: 0.094 sec
<<< FAILURE!

Results :

Tests in error:
  testCRUD(br.com.maweb.controlepeso.dao.UniversalDaoTest)
  testGetRoles(br.com.maweb.controlepeso.dao.LookupDaoTest)
 
testAddAndRemoveControlePeso(br.com.maweb.controlepeso.dao.ControlePesoDaoTest)
  testGetRoleInvalid(br.com.maweb.controlepeso.dao.RoleDaoTest)
  testGetRole(br.com.maweb.controlepeso.dao.RoleDaoTest)
  testUpdateRole(br.com.maweb.controlepeso.dao.RoleDaoTest)
  testAddAndRemoveRole(br.com.maweb.controlepeso.dao.RoleDaoTest)
  testFindByNamedQuery(br.com.maweb.controlepeso.dao.RoleDaoTest)
  testGetUserInvalid(br.com.maweb.controlepeso.dao.UserDaoTest)
  testGetUser(br.com.maweb.controlepeso.dao.UserDaoTest)
  testGetUserPassword(br.com.maweb.controlepeso.dao.UserDaoTest)
  testUpdateUser(br.com.maweb.controlepeso.dao.UserDaoTest)
  testAddUserRole(br.com.maweb.controlepeso.dao.UserDaoTest)
  testAddAndRemoveUser(br.com.maweb.controlepeso.dao.UserDaoTest)
  testUserExists(br.com.maweb.controlepeso.dao.UserDaoTest)
  testUserNotExists(br.com.maweb.controlepeso.dao.UserDaoTest)

Tests run: 16, Failures: 0, Errors: 16, Skipped: 0

[INFO]
------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO]
------------------------------------------------------------------------
[INFO] There are test failures.

Please refer to D:\workspaces\projetos\controlepeso\target\surefire-reports
for the individual test results.
[INFO]
------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 7 seconds
[INFO] Finished at: Tue Oct 07 18:06:35 BRT 2008
[INFO] Final Memory: 21M/38M
[INFO]
------------------------------------------------------------------------

D:\workspaces\projetos\controlepeso>
 



mraible wrote:
> 
> Did you make sure your class is mapped in hibernate.cfg.xml?
> 
> Matt
> 
> On Tue, Oct 7, 2008 at 9:08 AM, mmaia <[EMAIL PROTECTED]> wrote:
> 
>> 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.
>> br.com.maweb.controlepeso.dao.UserDaoTest.txt<http://www.nabble.com/file/p19860344/br.com.maweb.controlepeso.dao.UserDaoTest.txt>
>> ------------------------------
>> View this message in context: OneToMany Relation Problem from
>> User<http://www.nabble.com/OneToMany-Relation-Problem-from-User-tp19860344s2369p19860344.html>
>> Sent from the AppFuse - User mailing list
>> archive<http://www.nabble.com/AppFuse---User-f2370.html>at Nabble.com.
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/OneToMany-Relation-Problem-from-User-tp19860344s2369p19867348.html
Sent from the AppFuse - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to