2

Is it possible to set multiple SQL column types for an hibernate 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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, in fact I am trying to modify code that I have not written and the types in hbm.xml files are specified as java type instead of hibernate types and I did not know the difference.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.