Hi all,
Would JBoss validate an Entity's attribute for length?
@Entity public class ExampleName implements Serializable { ... private String name; @Column(nullable = false, length=25) public String getName() { ... }
ExampleName ex = new ExampleName(); ex.setName("A long line that violates the max length set for ExampleName");
12:35:37,312 WARN [JDBCExceptionReporter] SQL Error: 8152, SQLState: 22001
12:35:37,312 ERROR [JDBCExceptionReporter] String or binary data would be truncated.
12:35:37,312 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
org.hibernate.exception.DataException: could not insert: [com.judots.ExampleName]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:77)
...
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: String or binary data would be truncated.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
java.lang.reflect.UndeclaredThrowableException
at $Proxy5.createExchange(Unknown Source)
at com.judots.test.Tests.createExampleName(Tests.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
...
Caused by: java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerException
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
...