annotation to explicitly select a "long string" or "text" column type #4396
Replies: 6 comments 38 replies
-
Out of curiosity, what would be the equivalent in XML mapping? I'm asking because we would have had a use for something similar in Hibernate Search, where we are currently forced to use XML mapping (the only solution for entities added by a third-party library on startup, without user configuration). We would have been able to reference a type with a name, but we wouldn't be able to use an annotation. Though the use case in Hibernate Search is similar, but not exactly the same: we needed a binary type rather than a text type. We gave up and just used |
Beta Was this translation helpful? Give feedback.
-
To make any sorta progress on this one we need to compile a list of the "text" or "long varchar" types for the main platforms. This is nontrivial, since the databases are very divergent in this area. Tell me if these are right/wrong:
WDYT? |
Beta Was this translation helpful? Give feedback.
-
@gavinking I agree that this is not "terrible":
But I do think it somewhat defeats the purpose of the suggestion which is to allow seamless functionality with XML mappings. As you even pointed out, hand-coding that value in XML is error prone and, well, fugly.
Yep ^^
I mean, that's the general point wrt magic numbers. Nothing really unique about it here
Which is why I reversed course earlier and went with a negative number.
I wouldn't say hack... but how do users mapping with XML achieve this? |
Beta Was this translation helpful? Give feedback.
-
In many ways I like and agree with this, but 2 concerns:
|
Beta Was this translation helpful? Give feedback.
-
All told, I say this... they all make sense in their own right, each with pros and cons. I think it makes sense to support multiple of them. For annotation mappers, who are willing to use Hibernate annotations, I think
They all really describe the same thing. max/medium versus 32bit/16bit really target on different levels of user. For For pure JPA mappers (same for annotations and |
Beta Was this translation helpful? Give feedback.
-
+10000 |
Beta Was this translation helpful? Give feedback.
-
I believe it would be worth introducing a
@Long
or@LongString
or@MaxLength
annotation or something like that to make it easy for users to force the column type totext
orvarchar(max)
or whatever, without the use of@Lob
or JDBC-levelCLOB
APIs. On most dialects today,@Column(length=99999999)
probably works, but it's inelegant, and likely doesn't work very consistently. And this seems like it's probably a common-enough thing to want.Beta Was this translation helpful? Give feedback.
All reactions