ObjectDB ObjectDB

@Column length is not working.

#1

I am using objectdb 2.8.3, I have a Entity class with a column that is declared as @Column(unique = true, nullable = false, length = 16) but when i m trying to insert a string for that column with a string that has more than 16 character, not able to get any error or exception from ObjectDB. It should give an error for exceeding the limit. But dose not throwing any error or exception so its very difficult to validate the column string length. Please find the below project and objectdb file.

edit
delete
#2

ORM annotations, including @Column are silently ignored by ObjectDB, as specified in the documentation.

Regarding unique, you may use @Unique.

For other constraints, such as non null and length - consider checking relevant fields in a lifecycle event callback.

ObjectDB Support
edit
delete
#3

i think implementation of lifecycle event callback is expensive for check the length of a field. Is there any other way? 

edit
delete
#4

If by expensive you mean slow then it is not that expensive.

You can use external validation libraries, but they will not be faster.

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.