I've got a String column defined with
@Column(length = 4000)
The attribute contains log information and can be longer than the defined length. In this case, the field can be safely truncated without throwing an error message.
I'd like to find out the determined length of the column in the DAO class for the pojo so that I can truncate the string if necessary. How can I do that?
Regards,
Chris
The length of the roadway occupied by a column or a convoy in movement. See also road space. Dictionary of Military and Associated Terms.
Entity PropertiesPersistability - An object is called persistent if it is stored in the database and can be accessed anytime. Persistent Identity - In Java, each entity is unique and represents as an object identity.
In JPA Spec & javadoc: columnDefinition definition: The SQL fragment that is used when generating the DDL for the column. columnDefinition default: Generated SQL to create a column of the inferred type.
Check out EJB's answer to this question;
How to reuse fieldlength in form, validation and ddl ?
To paraphrase, if you wanted the length from the firstName column in the person table, you use this code.
person.getClass().getDeclaredField("firstName").getAnnotation(Column.class).length()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With