Is it possible to set multiple SQL column types for an hib开发者_StackOverflow中文版ernate property depending on the dialect used ? If yes how ?
For example, if i have a column of type char[]
, I would like to create a CLOB
type for Oracle and a Text
type in SQL Server.
The short answer is "no, it's not possible".
The long answer is "kind of, but you probably don't want to do that":
Hibernate would do that automatically to a certain extent - that is, when you define (implicitly or explicitly) a property of certain Hibernate type, it will translate that type to appropriate RDBMS-specific SQL type. Dialect and its descendants are responsible for that translation.
You could influence how that translation occurs - again, to a certain extent - by extending the dialect(s) you're working with (like Oracle or SQL Server) and registering your own column types. You're likely better off relying on default Hibernate type mappings, though.
精彩评论