db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "TINE Houari (OBJECTIVA)" <houari.t...@ca-cedicam.fr>
Subject About anonymous field
Date Tue, 22 Apr 2003 10:45:27 GMT
Hi,

In testcase OneToOneTest, the following code uses directly foreign-key
attribute (article.setProductGroupId(i)):

int i = 15;
broker.beginTransaction();
ProductGroup pg = new ProductGroup();
pg.setId(i);
pg.setGroupName("1-1 test productgroup " + i);
broker.store(pg);
broker.commitTransaction();
	
broker.beginTransaction();
Article article = Article.createInstance();
article.setArticleId(i);
article.setArticleName("1-1 test article " + i);
---------->article.setProductGroupId(i);
broker.retrieveReference(article, "productGroup");
broker.store(article);
broker.commitTransaction();

In order to allow this with anonymous field, I propose to add 2 new services
in broker:

1. public Object getAnonymousFieldValue(Object obj, String
anonymousFieldName)
2. public void setAnonymousFieldValue(Object obj, String anonymousFieldName,
Object value)

Last code becomes

int i = 15;
broker.beginTransaction();
ProductGroup pg = new ProductGroup();
pg.setId(i);
pg.setGroupName("1-1 test productgroup " + i);
broker.store(pg);
broker.commitTransaction();
	
broker.beginTransaction();
CleanArticle article = CleanArticle.createInstance();
article.setArticleId(i);
article.setArticleName("1-1 test article " + i);
---------->broker.setAnonymousFieldValue(article, "productGroupId",new
Integer(i));
broker.retrieveReference(article, "productGroup");
broker.store(article);
broker.commitTransaction();

What do you think?

Houar



Mime
View raw message