Model String field more than 255 characters

1,311 views
Skip to first unread message

thehellmaker

unread,
Sep 26, 2012, 2:21:12 AM9/26/12
to play-fr...@googlegroups.com
Hi All,
By default JPA in playframework defines string as varchar(255). Can we increase the length of the String field to a values I want ? If so could you please help me out as to how ? Is there an annotation to do this ?

Cheers,
Akash A

Mikael

unread,
Sep 26, 2012, 3:49:10 AM9/26/12
to play-fr...@googlegroups.com
@Column(columnDefinition = "nvarchar(500)", nullable = true)
public String field;

biesior

unread,
Sep 26, 2012, 6:34:47 AM9/26/12
to play-fr...@googlegroups.com
Mikael's answer relates to SQL Server, of course for other databases you should use another types in columnDefinition, ie text for MySQL (btw it was easier to guess if you wrote which DB are you using)

Mathias Clerc

unread,
Sep 26, 2012, 8:28:24 PM9/26/12
to play-fr...@googlegroups.com
Or you can use @Column(length = 300) to let JPA guess the column type
If you want to store very large text, you can use @Lob which has no
size limit (but is heavier on the DB)

2012/9/26 biesior <bie...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/hre4-eNrEyUJ.
> 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.

thehellmaker

unread,
Sep 28, 2012, 4:18:31 AM9/28/12
to play-fr...@googlegroups.com
Thanks a lot @Column works well for me. I dnt have  Lob requirement
Reply all
Reply to author
Forward
0 new messages