Hi,
I'm using castor 0.9.3 and postgres 7.1.
I'm trying to read an image and store it in the database. The field for that is set in the mapping file as
 
<field name="headerImage" type="bytes" >
      <sql name="header_image" type="binary" dirty="ignore"/>
      <xml name="headerImage" node="attribute"/>
    </field>
 
When I try to add image, I get the following exception
 
 Unknown Types value.
     at org.postgresql.jdbc2.PreparedStatement.setObject(PreparedStatement.java:552)
     at org.postgresql.jdbc2.PreparedStatement.setObject(PreparedStatement.java:558)
     at org.exolab.castor.jdo.engine.SQLTypes.setObject(SQLTypes.java:388)
     at org.exolab.castor.jdo.engine.SQLEngine.create(SQLEngine.java:596)
     at org.exolab.castor.persist.ClassMolder.create(ClassMolder.java:866)
     at org.exolab.castor.persist.LockEngine.create(LockEngine.java:474)
     at org.exolab.castor.persist.TransactionContext.create(TransactionContext.java:705)
     at org.exolab.castor.persist.ClassMolder.preStore(ClassMolder.java:1286)
     at org.exolab.castor.persist.LockEngine.preStore(LockEngine.java:710)
     at org.exolab.castor.persist.TransactionContext.prepare(TransactionContext.java:1146)
     at org.exolab.castor.jdo.engine.DatabaseImpl.commit(DatabaseImpl.java:498)
     at com.detsky.davis.test.castortest.TestBLOB.testCreateBLOB(TestBLOB.java:124)
     at java.lang.reflect.Method.invoke(Native Method)
     at junit.framework.TestCase.runTest(TestCase.java:166)
     at junit.framework.TestCase.runBare(TestCase.java:140)
     at junit.framework.TestResult$1.protect(TestResult.java:106)
     at junit.framework.TestResult.runProtected(TestResult.java:124)
     at junit.framework.TestResult.run(TestResult.java:109)
     at junit.framework.TestCase.run(TestCase.java:131)
     at junit.framework.TestSuite.runTest(TestSuite.java:173)
     at junit.framework.TestSuite.run(TestSuite.java:168)
     at junit.textui.TestRunner.doRun(TestRunner.java:74)
 
if I change my mapping file to
 
<field name="headerImage" type="bytes" >
      <sql name="header_image" type="blob" dirty="ignore"/>
      <xml name="headerImage" node="attribute"/>
    </field>
I get the same exception.
I've even tried using
<field name="headerImage" type="stream" >
      <sql name="header_image" type="blob" dirty="ignore"/>
      <xml name="headerImage" node="attribute"/>
    </field>
and also
<field name="headerImage" type="stream" >
      <sql name="header_image" type="binary" dirty="ignore"/>
      <xml name="headerImage" node="attribute"/>
    </field>
but no success.
 
Please, can any body help me in confirming if it is possible to store images in Postgres using castor.
 
TIA,
rabia

Reply via email to