I have some trouble mapping my java Objects to JSON columns in progress whil I want H2 to store it as clob (since there is no json type)
I use Hibernate with ddl-auto and want it to create the correct column types. In addition Spring-data-rest should be able to map the objects.
For sprint data rest it would be best to use a @Converter
, therefor I can't use @Type
/ UserTypes
for hibernate.
I have a working solution with a UserType
and 2 custom dialects (one for Postgres and one for H2). But I can't solve the problem with using converters. It seems Hibernate only knows the converted type, which is String
and generates varchar columns. But I can't map all Strings to JSON for Postgres ...
I'm a bit stuck here. So I would be happy for any hints that I can try out.
import javax.annotation.Nonnull
import javax.persistence.*
@Entity
class AdhocDocument {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
Long id
String lookupKey // use a guid here
String loggingKey // use a guid here
@Lob
@Column(name = "payload", columnDefinition="BLOB")
private byte[] payload
String toString() { "[${lookupKey}, ${loggingKey} ]"}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.