Hi
My entity has a java.net.URL property:
Code:
public URL getLogUrl(){..}
My DB is a mysql, and i m using Spring and JPA:
Code:
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceXmlLocation" value="WEB-INF/persistence.xml"/>
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true" /> <!-- Prints used SQL to stdout -->
<property name="generateDdl" value="true" /> <!-- Generates tables. -->
<property name="databasePlatform" value="org.hibernate.dialect.MySQL5Dialect" />
</bean>
</property>
</bean>
This creates the table with a tinyblob column for the URL, and then when persisting, the URL is saved by serializing it (which that alone is not good anyway). The problem is that when reading from the table, i get:
Code:
Caused by: org.hibernate.type.SerializationException: could not deserialize
Caused by: java.io.StreamCorruptedException: invalid stream header: 68747470
I've tried adding:
Code:
@Column(columnDefinition = "VARCHAR(1024)")
to the property. This persisted the URL as String, but when reading i got the same problem! Looks like it was written as String and read as blob.
How can i make the URL field be persisted as string (and read as one...)?