Persist Model object error : Data too long for column

760 views
Skip to first unread message

dino

unread,
Aug 1, 2011, 11:46:08 AM8/1/11
to play-framework
Hi,

I am having an error when persisting a Model Object with attribute :

@Required
@URL
@Column(name="url", length=1000)
@Length(max=1000)
public String url;

I use "jpa.ddl=create" in application.conf to create the tables in the
first execution, then I put the update value.

DDL creates a column url of type "longtext" in the MySql database.

When I save the object, I have the following error :
(JDBCExceptionReporter.java:233) - SQL Error: 1406, SQLState: 22001
(JDBCExceptionReporter.java:234) - Data truncation: Data too long for
column 'url' at row 1

The URL that causes me this problem has a length of 305 caracters.

I tried to increase the size of JPA annotation @Column to 10000 and to
explicitly specify argument "columnDefinition=longtext" but it doesn't
solve the problem.


Any ideas ?

The version of play is 1.2.2.

Thx

Adrian Perreau de Pinninck

unread,
Aug 5, 2011, 2:29:39 AM8/5/11
to play-fr...@googlegroups.com
Have you tried with @Lob, it worked for me.


--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.


dino

unread,
Aug 5, 2011, 4:10:53 AM8/5/11
to play-framework
Thx, I will try this solution :)

On 5 août, 08:29, Adrian Perreau de Pinninck <aperr...@gmail.com>
wrote:

Renato Oliveira

unread,
Aug 5, 2011, 8:31:53 AM8/5/11
to play-fr...@googlegroups.com
I am using something like this with no problem.

Longtext is working fine.
The only difference here is that I am not using the @Lenght annotation.
@Length annotation is a net.sf.oval.constraint.Length, you should try to stick with the play.data.validation.* annotations.

Here is my example:
    @MaxSize(4000)
    @Column(length=4000, nullable=false)
    public String description;


If this does not work, check how long is the String you are persisting? Is it possible that its size is greater than 1000? (maybe spaces on a textarea)

Hope it helps you.

Renato

2011/8/5 dino <alah...@gmail.com>
Reply all
Reply to author
Forward
0 new messages