How to use SQL Server varchar(max) in ORM entities

1,123 views
Skip to first unread message

Carl Von Stetten

unread,
Nov 4, 2011, 2:41:51 PM11/4/11
to cf-orm-dev
Microsoft SQL Server 2005 introduced varchar(max) as an eventual
replacement for the text data type, and eventually the text datatype
will be deprecated and removed from SQL Server. Is there any way to
start using varchar(max) with ColdFusion ORM/Hibernate now? I tried
setting a property with these settings:

property name="content" length="max";

CF threw the following error:

"Cannot convert length value max specified for property content in cfc
model.Post to an integer."

Any thoughts?

As an aside, I'm playing with the new "ColdFusion ORM" book by John
Whish - I'm on chapter 2 now.

-Carl

Michael Seid

unread,
Nov 5, 2011, 2:30:15 PM11/5/11
to cf-orm-dev
I am pretty sure you don't need to specify length.

Just set the property type="string", it will allow for any size. You
should do validation, but the field will now work with both
varchar(255) or text.

Carl Von Stetten

unread,
Nov 6, 2011, 9:45:35 PM11/6/11
to cf-orm-dev
Michael,

Yeah, but how do you get ColdFusion ORM/Hibernate to create
varchar(max) columns? There are situations where varchar(8000) may
not be big enough, but I'd like to avoid using the text data type
because (a) it's going to be deprecated out at some point, and (b) you
can't use the LIKE or SUBSTRING on text columns under certain
situations,

Carl

Tony Nelson

unread,
Nov 7, 2011, 9:15:50 AM11/7/11
to cf-orm-dev
property name="content" type="string" sqltype="varchar(max)";

Carl Von Stetten

unread,
Nov 7, 2011, 10:52:36 AM11/7/11
to cf-or...@googlegroups.com
Tony,

Thanks, I'll try that out. Still getting my feet wet with ORM. I'm
guessing if I had read all of the CF ORM docs, I'd have found that
answer. I'll try to RTFM more in the future, I promise. :-[

Carl

Michael Seid

unread,
Nov 7, 2011, 12:52:42 PM11/7/11
to cf-orm-dev
Glad you got it figured out. I never actually have ORM create my DB
so I have no experience in that aspect. I much prefer to do the SQL
separate and uses ORM mapping the model.

Carl Von Stetten

unread,
Nov 7, 2011, 1:28:15 PM11/7/11
to cf-or...@googlegroups.com
I probably will do the same on my future ORM projects. Right now, I'm
learning ORM by working through John Whish's new book, which has ORM
create the tables. I just wanted to see if I could get ORM to create
the tables exactly the way I wanted, which it appears I can.

-Carl

John Whish

unread,
Nov 9, 2011, 4:12:46 AM11/9/11
to cf-or...@googlegroups.com
Just to hop in on the conversation, when I build apps with ORM, I
often get Hibernate to generate the "rough" schema for me so that I
focus on the "model" rather than the database schema, but I will then
tune the schema database at the database level before putting it into
production.

This partly so that I can save the schema / sql dump in version
control when I tag the project at the point it goes live and secondly
I don't like having too much code in my CFCs that relate to the
database schema - for the most part I want to ignore the database, and
it's only useful the first time you create the database.

- John

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

Reply all
Reply to author
Forward
0 new messages