This is a wiki page for the RiftSaw-306 issue.
Sybase JConnector dirver doesn't support the 'text' data type with null value. It is having problem as same as this jira issue. http://opensource.atlassian.com/projects/hibernate/browse/HHH-3975 Because the JPA's @Lob annotation will generate the 'text' data column type in Hibernate.
Unperfect workaround (by using jTDS driver):
One workaround to this problem would be to use the jTDS driver, but this dirver does NOT support XA transaction for sybase. If you don't need to have XA transaction support, you can take this approach by doing following updates.
1) update your jdbc Driver class to: net.sourceforge.jtds.jdbc.Driver
2) update your connection url in following format: jdbc:jtds:sybase://localhost:5000/database
Experiments on using jConnector driver :
1. using hibernate specific annotation.
[Jeff Yu] below is the steps for adding hibernate specific annotation.
1) Added a class for SybaseText, like this one from jBPM3 source code.
2) Added a package-info.java class with the content like following:
By using the hibernate specific annotatioins in the source code, because we used the annotation, this means that all databases will share the same metadata, this means that we can NOT use this approach, as it will break all the other existing databases.
In the JPA specification, we can override annotations by using orm.xml, but current orm.xml doesn't support the vendor extension support, so we can NOT define the custom data map as what jBPM3 did in the hibernate configuration file.
2. set default NULL value.
[Jeff Yu] I tried to add @prePersist, @preUpdate to add the default NULL value for the 'text' fields. The involved Entities are: ActivityRecoveryDAO, FaultDAO, MessageDAO, MessageExchangeDAO, PartnerLinkDAO and XmlDataDAO. Also need to add the @postPersist, @postUpdate and @postLoad to set those fields back to null if their value is the default NULL value.
After I've added these listeners, I found that it also has problem with the 'image' data type, this 'image' data type doesn't go well with the null value, so I need to add a listener for the ProcessInstanceDAO entity.
After this, I've seen the following error:
23:25:07,462 WARN [EndpointFactory] Couldnt create any endpoint for element <?xml version="1.0" encoding="UTF-8"?>
23:25:07,841 INFO [STDOUT] class org.apache.ode.dao.jpa.listener.MessageExchangeDAOSybaseListenerNUll value
23:25:07,852 ERROR [BpelRuntimeContextImpl] Couldn't find endpoint for partner EPR <?xml version="1.0" encoding="UTF-8"?>
I've used the '<?xml version="1.0" encoding="UTF-8"?><data>null</data>' for default NULL value, it seems to me that when I set the field into object, it gets passed to other places before it goes to the @PostPersist method, which will set the model back to null value.
Also, with this approach, it may adds performance burder, cause it will go through these 7 Listeners, although for current existing working databases, like postgres, mysql, oracle etc.
So this approach doesn't look like a viable solution.
3. Using hibernat.ejb.cfgfile
Hiberante EntityManager offere a property that can be used to point to a hibernate.cfg.xml file. .. To Be Continued....
[Jeff Yu] Given current Apache ODE supports both OpenJPA and Hibernate by using JPA annotation, also current JPA xml configuration file doesn't support vendor extension (like something we can add for Hibernate JPA provider only), it is very hard for us to fix this sybase support issue. Tried the set default 'NULL' value approach, as I described above, didn't make to work either.
So if we want to support the jConnector driver, we will need to fall back our JPA annotation to the Hibernate xml configuration file, as what we did on jBPM3, but this would have problem for the ODE community, as they go with OpenJPA.
What do you think?