Hello everybody
I got into trouble with Castor and PostgreSQL. I'm currently using Castor
0.9.5.3 and PostgreSQL 7.4.2 with the pg74.213.jdbc3.jar JDBC-driver.
I have several problems:
Connection-Pooling:
If my database.xml looks like this:
<---------------------------------------------------------------------->
<database name="dbsa" engine="postgresql">
<data-source class-name="org.postgresql.jdbc2.optional.PoolingDataSource">
<params server-name="localhost" database-name="dbsa"
initial-connections="2" max-connections="10"
user="dbsa" password="seminarverwaltung" />
</data-source>
<mapping href="res/dbsa-mapping.xml" />
</database>
<---------------------------------------------------------------------->
I get errors like this:
<---------------------------------------------------------------------->
Exception: org.exolab.castor.mapping.MappingException: Nested error:
java.lang.NullPointerException
org.exolab.castor.jdo.DatabaseNotFoundException: No configuration loaded for
database dbsa -- use the JDO interface to load a configuration for this
database
at org.exolab.castor.jdo.JDO.getDatabase(JDO.java:601)
at ch.fhz.hta.dbsa.server.db.ModifyBroker.<init>(ModifyBroker.java:54)
at Test.<init>(Test.java:49)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at junit.framework.TestSuite.createTest(TestSuite.java:131)
at junit.framework.TestSuite.addTestMethod(TestSuite.java:114)
at junit.framework.TestSuite.<init>(TestSuite.java:75)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.getTest(RemoteTestRunner.java:349)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:387)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:294)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:182)
<---------------------------------------------------------------------->
If I use instead the normal driver like this:
<---------------------------------------------------------------------->
<database name="dbsa" engine="postgresql">
<driver url="jdbc:postgresql://localhost/dbsa"
class-name="org.postgresql.Driver">
<param name="user" value="dbsa" />
<param name="password" value="seminarverwaltung" />
</driver>
<mapping href="res/dbsa-mapping.xml" />
</database>
<---------------------------------------------------------------------->
everything works fine. I don't know wheter PostgreSQL 7.4 supports
connection-pooling. I just read that version 7.2 should have support for it.
Or must I use Poolman as a pooling manager?
Well the next point is much more important. In the documentation is only
written that database-locking works with Oracle and Sybase. But it is nowhere
mentioned that it also works with PostgreSQL. But on the other hand in the
JDO-FAQ it is written, that PostgreSQL supports the main functions of Castor.
Because we are developing a three tier client, we can't use caching. The cache
is disabled and we are requesting every object direct from the database. As a
consequence we must lock a record on the database as soon as we want to
modify the desired object (the business-layer is distributed on different
machines).
I tried to load the object with access-mode (short)3.
But then PostgreSQL complains:
<---------------------------------------------------------------------->
May 28, 2004 11:47:31 PM org.exolab.castor.jdo.engine.SQLEngine load
SEVERE: A fatal error occurred while loading
ch.fhz.hta.dbsa.server.entities.Organization using SQL: SELECT
"room"."room_id","organization"."address","organization"."city","organization"."contact_person_department","organization"."contact_person_first_name","organization"."contact_person_last_name","organization"."contact_person_telefon_number","organization"."fax_number","organization"."name","organization"."organization_size","organization"."short_name","organization"."telefon_number","organization"."zip_code","organization"."is_deleted","organization"."last_edited"
FROM "organization" LEFT OUTER JOIN "room" ON
"organization"."organization_id"="room"."organization_id" WHERE
"organization"."organization_id"=? FOR UPDATE
org.postgresql.util.PSQLException: ERROR: SELECT FOR UPDATE cannot be applied
to the nullable side of an outer join
<---------------------------------------------------------------------->
The problem is obviously, that the Organization-Object holds a collection of
Rooms (a reference would also lead to the error). But as long as this
collection is empty (or the reference is null), PostgreSQL complains about
the nullable side of the outer join.
Is there any solution available?
And my last question is about lazy loading.
I have the Room class with a relation (1:1) to the Organization class.
<---------------------------------------------------------------------->
class Room {
private Collection m_oOrganization;
(...)
public void setM_oOrganization (Collection organization) {}
public Collection getM_oOrganization ()
}
<---------------------------------------------------------------------->
class Organization { (..) }
<---------------------------------------------------------------------->
<class name="Room" (...)>
<map-to table="room" />
<cache-type type="none" />
<field name="m_oOrganization" type="Organization" lazy="true"
collection="collection">
<sql name="organization_id" />
</field>
(...)
<---------------------------------------------------------------------->
As soon as I call the create(Object)-method and pass a Room-object
I receive following error:
<---------------------------------------------------------------------->
org.exolab.castor.jdo.PersistenceException: Nested error:
java.lang.NumberFormatException: For input string: "[]"
at
org.exolab.castor.persist.TransactionContext.create(TransactionContext.java:921)
at org.exolab.castor.jdo.engine.DatabaseImpl.create(DatabaseImpl.java:363)
at ch.fhz.hta.dbsa.server.db.ModifyBroker.createRoom(ModifyBroker.java:177)
<---------------------------------------------------------------------->
Regards,
Stefan
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user