Have you ever used ibatis to load a blob field?
The resul bean seems to be ok, but when I try to used the blob property I have a NullPointerException even if the property isn't really null
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Due to some driver incompatibilities with BLOBs (*COUGH* oracle *COUGH*), I have yet to seriously implement BLOBs. Although CLOBs are supported for read-only, and byte[] is supported to the level of the driver.
Until the driver vendors implement this in a consistent way, it will be very difficult to implement in SqlMap without introducing database specific extensions (something I've been trying to avoid for sanity sake).
Hopefully blobs are rare in your application and you can just write the JDBC for it. Using the DAO framework you can still achieve a consistent persistence API, even if you use SqlMaps in some cases and JDBC in others.
Cheers,
Clinton
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
At this time, that is what I recommend. CLOB/BLOB support is actually at the bottom of the priority list based on the number of requests. If more people were interested in it, I would work on it right away. Like I said though, part of the complication is the fact that JDBC driver vendors implement things differently. In some cases even the semantics are different (e.g. cannot insert blob, only update etc.)
Sorry for the inconvenience. Perhaps I'll look into it in the next couple of weeks.
Cheers,
Clinton
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Keep it as low priority your framework is excelent for all the other stuff. Using CLOBS you usually also has to set somekind of encoding and other params that is specific to the dabase (eg Oracle).
Implement the paging support instead :) ... please.
/Claus
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The only issue I have with this is that it looks to me like the business class (Foo) has a property of type CLOB. The point of O/R mapping with Hibernate and/or SQL mapping with Sql Maps is to isolate your business (domain) classes from the persistence details. I would prefer to see an implementation where Foo had a String property and the SqlMap could simply state #property:CLOB# to write the CLOB via the SqlMap.
This would be quite easy to implement, if only the database vendors would follow the spec!
Perhaps I'll implement it this way anyway, so that databases that are compliant can leverage LOB support easily.
Cheers,
Clinton
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yeah the CLOB issue is anoying. I had to write some weird Oracle/Weblogic JDBC code to write a CLOB to the Database. Now the implementation is totally dependent on:
- using Weblogic jDriver for Oracle
- using Weblogic
- using Oracle8i
I know I'll have to write another implementation for the Websphere AS using another JDBC driver.
/Claus
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Have you ever used ibatis to load a blob field?
The resul bean seems to be ok, but when I try to used the blob property I have a NullPointerException even if the property isn't really null
Due to some driver incompatibilities with BLOBs (*COUGH* oracle *COUGH*), I have yet to seriously implement BLOBs. Although CLOBs are supported for read-only, and byte[] is supported to the level of the driver.
Until the driver vendors implement this in a consistent way, it will be very difficult to implement in SqlMap without introducing database specific extensions (something I've been trying to avoid for sanity sake).
Hopefully blobs are rare in your application and you can just write the JDBC for it. Using the DAO framework you can still achieve a consistent persistence API, even if you use SqlMaps in some cases and JDBC in others.
Cheers,
Clinton
So when I have to store data as a CLOB I'll have to use normal JDBC ?
At this time, that is what I recommend. CLOB/BLOB support is actually at the bottom of the priority list based on the number of requests. If more people were interested in it, I would work on it right away. Like I said though, part of the complication is the fact that JDBC driver vendors implement things differently. In some cases even the semantics are different (e.g. cannot insert blob, only update etc.)
Sorry for the inconvenience. Perhaps I'll look into it in the next couple of weeks.
Cheers,
Clinton
Clinton
Keep it as low priority your framework is excelent for all the other stuff. Using CLOBS you usually also has to set somekind of encoding and other params that is specific to the dabase (eg Oracle).
Implement the paging support instead :) ... please.
/Claus
Hello, Clinton
Could you implements Blob support like hibernate2 do like following, Thanks.
s = sf.openSession();
tx = s.beginTransaction();
foo = new Foo();
foo.setClob( Hibernate.createClob(" ") );
s.save(foo);
s.flush();
s.refresh(foo, LockMode.UPGRADE); //grabs an Oracle CLOB
oracle.sql.CLOB clob = (oracle.sql.CLOB) foo.getClob();
java.io.Writer pw = clob.getCharacterOutputStream();
pw.write(content);
pw.close();
tx.commit();
s.close();
The only issue I have with this is that it looks to me like the business class (Foo) has a property of type CLOB. The point of O/R mapping with Hibernate and/or SQL mapping with Sql Maps is to isolate your business (domain) classes from the persistence details. I would prefer to see an implementation where Foo had a String property and the SqlMap could simply state #property:CLOB# to write the CLOB via the SqlMap.
This would be quite easy to implement, if only the database vendors would follow the spec!
Perhaps I'll implement it this way anyway, so that databases that are compliant can leverage LOB support easily.
Cheers,
Clinton
Hi Clinton
Yeah the CLOB issue is anoying. I had to write some weird Oracle/Weblogic JDBC code to write a CLOB to the Database. Now the implementation is totally dependent on:
- using Weblogic jDriver for Oracle
- using Weblogic
- using Oracle8i
I know I'll have to write another implementation for the Websphere AS using another JDBC driver.
/Claus