Hi Geert,
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?
I'm using :
MySQL : 4.1.12
RIFE : rife-1.4-jdk15.jar, it's the "regular" RIFE, not jumpstart
JDBC driver : 3.1.12
JDK : 1.5.0_04-b05
All of this running on Kubuntu OS : http://www.kubuntu.org
"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.
For what i've seen here in France, while lot of developpers have just
discovered Hibernate, the few who have been using it are just moving
backwards, to good old JDBC, due to Hibernate's complexity. It seems
that RIFE's easy to configure persistance framework should be a good
selling argument ! But please keep this simplicity : i'm afraid that
adding too many features would drive to RIFE's persistance to a
Hibernate clone, and the inherent problems. It's not such a big deal if
we have to handle associations manually.
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.
I'm going to try this, when my problem is solved.
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
_______________________________________________
Rife-users mailing list
[email protected]
http://lists.uwyn.com/mailman/listinfo/rife-users