Hi Laki,
At this point, my feelings are : Wow ! Great ! My table is created
with no effort, no complex configuration ! (Even though i didn't
find out how to provide a different type than int for the primarykey).
And the save performed without problem ! Hum... Wait.... Actually
there is a big problem : my data were inserted in a weird way : the
city in place of zip code, and so on : only the primarykey is at
the right place ! What did i miss ?
Strange, very strange. I copy/pasted your code in the jumpstart and
everything worked perfectly with MySQL Max 5.0.19 and the driver
mysql-connector-java-3.1.12-bin.jar
Which versions are you using?
"Setting a typed parameter is not supported for index '1', target
type 'testpackage.beans.Address and value
'[EMAIL PROTECTED]'.
What is the right way to handle associations between beans ?
This is one of the things missing from RIFE's persistence. The way
people have been handling it is by using callbacks that fills in the
association property after the restore. We're still looking for a
good way to handle this. Personally I just use and 'addressId'
property in the Person class that is a foreign key. When I need the
corresponding Address instance, I just just the GenericQueryManager
to get it from the database.
However, judging from the interest in this issue lately, I'll try to
find a good solution and implementation for it in the coming weeks.
After looking at my code, i'm not sure about the necessity of
having a DAO for each bean, while i could call a "save" or "load"
when i need them, for example directly in an element. But it would
imply that i call something like
GenericQueryManager manager = GenericQueryManagerFactory
.getInstance(Datasources.getRepInstance().getDatasource
("mysql"),
Address.class);
before each operation...
Is there a simpler way to access a manager in elements?
Yes, you can put them in a participant and then use a property that
will automatically be injected into each element.
public class ManagerParticipant extends BlockingParticipant {
private GenericQueryManager<Address> mAddressManager;
protected void initialize() {
Datasource d = Datasources.getRepInstance().getDatasource
("mysql");
mAddressManager = GenericQueryManagerFactory.getInstance(d,
Address.class);
}
protected Object _getObject(Object key) {
if ("address".equals(key)) return mAddressManager;
return null;
}
}
<rep>
...
<participant
name="Managers">com.uwyn.rife.jumpstart.ManagerParticipant</participant>
...
</rep>
<site>
...
<property name="addressManager">
<participant name="Managers">address</participant>
</property>
<element ...>
</element>
...
</site>
and then in your elements in that site (or sub-sites):
((GenericQueryManager)getProperty("addressManager")).insert(adr)
or with JDK 1.5
getPropertyTyped("addressManager", GenericQueryManager.class).insert
(adr)
Of course, there's nothing that prevents you from just putting the
long winded version in a static method and calling it like that.
Hope this helps,
Geert
--
Geert Bevin Uwyn bvba GTalk: [EMAIL PROTECTED]
"Use what you need" Avenue de Scailmont 34 Skype: gbevin
http://www.uwyn.com 7170 Manage, Belgium AIM: geertbevin
gbevin at uwyn dot com Tel: +32 64 84 80 03 Mobile: +32 477 302 599
PGP Fingerprint : 4E21 6399 CD9E A384 6619 719A C8F4 D40D 309F D6A9
Public PGP key : available at servers pgp.mit.edu, wwwkeys.pgp.net
_______________________________________________
Rife-users mailing list
[email protected]
http://lists.uwyn.com/mailman/listinfo/rife-users