Diego Ballve
2005-04-19 10:34:08 UTC
Hello,
I'm trying to use middlegen in a database w/ multiple many-to-many and
I'm getting StrutsXXXDelegate to call undefined methods like
TranslatorUtil.copyPersistenceToVo(Collection, XXXForm);
For instance, I have defined
<many2many>
<tablea generate="true" name="ACCOUNT" />
<jointable name="ACCOUNT_CREDENTIALS" generate="false" />
<tableb generate="true" name="CREDENTIALS" />
</many2many>
For my database definiton:
create table credentials (
id varchar(255) not null,
primary key (id)
)
create table account (
id varchar(255) not null,
password varchar(255),
expiration_time bigint,
owner varchar(255) not null,
primary key (id)
)
create table account_credentials (
account_id varchar(255) not null,
credential_id varchar(255) not null,
primary key (credential_id, account_id)
)
alter table account_credentials add constraint FK10022FEAA77C1603
foreign key (credential_id) references credentials
alter table account_credentials add constraint FK10022FEAD01E1C6D
foreign key (account_id) references account
But I get middlegen generating
public class StrutsAccountDelegate {
...
/**
* This method will return all objects referenced by Credential
*/
public static List getCredential(airline.web.struts.AccountForm
accountForm) throws Exception {
List retVals = new ArrayList();
airline.hibernate.Account accountPersistence = null;
javax.naming.InitialContext ctx = new javax.naming.InitialContext();
// TODO: Make adapter get SessionFactory jndi name by ant task argument?
net.sf.hibernate.SessionFactory factory =
(net.sf.hibernate.SessionFactory)ctx.lookup("java:AirlineHibernateFactory");
net.sf.hibernate.Session session = factory.openSession();
net.sf.hibernate.Transaction tx = session.beginTransaction();
accountPersistence =
(airline.hibernate.Account)session.load(airline.hibernate.Account.class,
accountPersistence.getId());
tx.commit();
session.close();
retVals.add(accountPersistence.getCredentials());
ArrayList CREDENTIAL_ID_vos = new ArrayList();
for (Iterator it = retVals.iterator(); it.hasNext(); ) {
airline.web.struts.CredentialForm CREDENTIAL_ID_Temp = new
airline.web.struts.CredentialForm();
java.util.Collection CREDENTIAL_ID_PO =
(java.util.Collection)it.next();
TranslatorUtil.copyPersistenceToVo(CREDENTIAL_ID_PO,
CREDENTIAL_ID_Temp);
CREDENTIAL_ID_vos.add(CREDENTIAL_ID_Temp);
}
retVals = CREDENTIAL_ID_vos;
return retVals;
}
}
It seems that middlegen is mapping the collection and not the collection
items.. I've spend some time trying to figure out why but I'm stuck!
what am I missing?
Thanks,
Diego
I'm trying to use middlegen in a database w/ multiple many-to-many and
I'm getting StrutsXXXDelegate to call undefined methods like
TranslatorUtil.copyPersistenceToVo(Collection, XXXForm);
For instance, I have defined
<many2many>
<tablea generate="true" name="ACCOUNT" />
<jointable name="ACCOUNT_CREDENTIALS" generate="false" />
<tableb generate="true" name="CREDENTIALS" />
</many2many>
For my database definiton:
create table credentials (
id varchar(255) not null,
primary key (id)
)
create table account (
id varchar(255) not null,
password varchar(255),
expiration_time bigint,
owner varchar(255) not null,
primary key (id)
)
create table account_credentials (
account_id varchar(255) not null,
credential_id varchar(255) not null,
primary key (credential_id, account_id)
)
alter table account_credentials add constraint FK10022FEAA77C1603
foreign key (credential_id) references credentials
alter table account_credentials add constraint FK10022FEAD01E1C6D
foreign key (account_id) references account
But I get middlegen generating
public class StrutsAccountDelegate {
...
/**
* This method will return all objects referenced by Credential
*/
public static List getCredential(airline.web.struts.AccountForm
accountForm) throws Exception {
List retVals = new ArrayList();
airline.hibernate.Account accountPersistence = null;
javax.naming.InitialContext ctx = new javax.naming.InitialContext();
// TODO: Make adapter get SessionFactory jndi name by ant task argument?
net.sf.hibernate.SessionFactory factory =
(net.sf.hibernate.SessionFactory)ctx.lookup("java:AirlineHibernateFactory");
net.sf.hibernate.Session session = factory.openSession();
net.sf.hibernate.Transaction tx = session.beginTransaction();
accountPersistence =
(airline.hibernate.Account)session.load(airline.hibernate.Account.class,
accountPersistence.getId());
tx.commit();
session.close();
retVals.add(accountPersistence.getCredentials());
ArrayList CREDENTIAL_ID_vos = new ArrayList();
for (Iterator it = retVals.iterator(); it.hasNext(); ) {
airline.web.struts.CredentialForm CREDENTIAL_ID_Temp = new
airline.web.struts.CredentialForm();
java.util.Collection CREDENTIAL_ID_PO =
(java.util.Collection)it.next();
TranslatorUtil.copyPersistenceToVo(CREDENTIAL_ID_PO,
CREDENTIAL_ID_Temp);
CREDENTIAL_ID_vos.add(CREDENTIAL_ID_Temp);
}
retVals = CREDENTIAL_ID_vos;
return retVals;
}
}
It seems that middlegen is mapping the collection and not the collection
items.. I've spend some time trying to figure out why but I'm stuck!
what am I missing?
Thanks,
Diego