You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Bengt Rodehav <be...@rodehav.com> on 2012/04/02 08:59:09 UTC

Re: Problems with SQLServer VARCHAR(MAX)

Has no one else encountered this? Does someone has any ideas of how to get
rid of this?

/Bengt

2012/3/29 Bengt Rodehav <be...@rodehav.com>

> I'm using OpenJPA 2.1.1 with Microsoft SQLServer 2005.
> In one of my entities I have a field that can potentially be quite large
> (it represents an incoming XML message). I therefore store it in a column
> defined as "VARCHAR(MAX)". This possibility was introduced in SQLServer
> 2005 and allows storing strings up to 2GB in size.
>
> I annotate my field as follows:
>
> *...*
> *  @Column(columnDefinition = "VARCHAR(MAX)")*
> *  private String originalEntry;*
> *...*
>
> The column is created with the correct type by OpenJPA. However, I get the
> following warning in my logs:
>
> *18078  lafaPU  WARN   [Camel (LAFA) thread #1 - file://~dp0/../../..*
> */common/data/interfaces/sample/lafa] openjpa.jdbc.Schema - Existing
> column "originalEntry" on table "dbo.LafaEntry" is incompatible with the
> same column in thegiven schema definition.*
> *Existing column:*
> *Full Name: LafaEntry.originalEntry*
> *Type: longvarchar*
> *Size: 2147483647*
> *Default: null*
> *Not Null: false*
> *Given column:*
> *Full Name: LafaEntry.originalEntry*
> *Type: varchar*
> *Size: 255*
> *Default: null*
> *Not Null: false*
>
> Does anyone know why this is happening and how I can get rid of the
> warnings? Is SQLServer 2005 supported by OpenJPA?
>
> BTW, the warnings don't seem to be saved in my log files - they only
> appear on stdout. Doesn't seem right to me.
>
> /Bengt
>
>
>

Re: Problems with SQLServer VARCHAR(MAX)

Posted by Bengt Rodehav <be...@rodehav.com>.
Thanks for your answer John but SQLServer does not recognize that syntax
although OpenJPA might. The syntax "VARCHAR(MAX)" has special meaning to
SQLServer 2005. The "MAX" means that it shall try to inline the column in
the current row if there is enough space, otherwise create a separate large
object for it. If I specify an integer instead of "MAX", that integer
cannot be larger than 8000.

OpenJPA must recognize the special syntax "VARCHAR(MAX) and then assume
that the maximum size is 2 GB.

/Bengt

2012/4/2 Boblitz John <Jo...@bertschi.com>

>
>
> > -----Ursprüngliche Nachricht-----
> > Von: bengt.rodehav@gmail.com [mailto:bengt.rodehav@gmail.com]
> > Im Auftrag von Bengt Rodehav
> > Gesendet: Montag, 2. April 2012 08:59
> > An: users@openjpa.apache.org
> > Betreff: Re: Problems with SQLServer VARCHAR(MAX)
> >
> > Has no one else encountered this? Does someone has any ideas
> > of how to get rid of this?
> >
> > /Bengt
> >
> > 2012/3/29 Bengt Rodehav <be...@rodehav.com>
> >
> > > I'm using OpenJPA 2.1.1 with Microsoft SQLServer 2005.
> > > In one of my entities I have a field that can potentially be quite
> > > large (it represents an incoming XML message). I therefore
> > store it in
> > > a column defined as "VARCHAR(MAX)". This possibility was
> > introduced in
> > > SQLServer
> > > 2005 and allows storing strings up to 2GB in size.
> > >
> > > I annotate my field as follows:
> > >
> > > *...*
> > > *  @Column(columnDefinition = "VARCHAR(MAX)")*
> > > *  private String originalEntry;*
> > > *...*
> > >
> > > The column is created with the correct type by OpenJPA.
> > However, I get
> > > the following warning in my logs:
> > >
> > > *18078  lafaPU  WARN   [Camel (LAFA) thread #1 -
> > file://~dp0/../../..*
> > > */common/data/interfaces/sample/lafa] openjpa.jdbc.Schema -
> > Existing
> > > column "originalEntry" on table "dbo.LafaEntry" is
> > incompatible with
> > > the same column in thegiven schema definition.* *Existing column:*
> > > *Full Name: LafaEntry.originalEntry*
> > > *Type: longvarchar*
> > > *Size: 2147483647*
> > > *Default: null*
> > > *Not Null: false*
> > > *Given column:*
> > > *Full Name: LafaEntry.originalEntry*
> > > *Type: varchar*
> > > *Size: 255*
> > > *Default: null*
> > > *Not Null: false*
> > >
> > > Does anyone know why this is happening and how I can get rid of the
> > > warnings? Is SQLServer 2005 supported by OpenJPA?
> > >
> > > BTW, the warnings don't seem to be saved in my log files -
> > they only
> > > appear on stdout. Doesn't seem right to me.
> > >
> > > /Bengt
> > >
> > >
> > >
> >
>
> No idea if this will work, but did you try:
>
> @Column(columnDefinition = "VARCHAR(2147483647)")
>
> 
>
> John
>
> ----
>
> Who is General Failure, and why is he reading my hard disk?
>
>
>

AW: Problems with SQLServer VARCHAR(MAX)

Posted by Boblitz John <Jo...@BERTSCHI.com>.
 

> -----Ursprüngliche Nachricht-----
> Von: bengt.rodehav@gmail.com [mailto:bengt.rodehav@gmail.com] 
> Im Auftrag von Bengt Rodehav
> Gesendet: Montag, 2. April 2012 08:59
> An: users@openjpa.apache.org
> Betreff: Re: Problems with SQLServer VARCHAR(MAX)
> 
> Has no one else encountered this? Does someone has any ideas 
> of how to get rid of this?
> 
> /Bengt
> 
> 2012/3/29 Bengt Rodehav <be...@rodehav.com>
> 
> > I'm using OpenJPA 2.1.1 with Microsoft SQLServer 2005.
> > In one of my entities I have a field that can potentially be quite 
> > large (it represents an incoming XML message). I therefore 
> store it in 
> > a column defined as "VARCHAR(MAX)". This possibility was 
> introduced in 
> > SQLServer
> > 2005 and allows storing strings up to 2GB in size.
> >
> > I annotate my field as follows:
> >
> > *...*
> > *  @Column(columnDefinition = "VARCHAR(MAX)")*
> > *  private String originalEntry;*
> > *...*
> >
> > The column is created with the correct type by OpenJPA. 
> However, I get 
> > the following warning in my logs:
> >
> > *18078  lafaPU  WARN   [Camel (LAFA) thread #1 - 
> file://~dp0/../../..*
> > */common/data/interfaces/sample/lafa] openjpa.jdbc.Schema - 
> Existing 
> > column "originalEntry" on table "dbo.LafaEntry" is 
> incompatible with 
> > the same column in thegiven schema definition.* *Existing column:* 
> > *Full Name: LafaEntry.originalEntry*
> > *Type: longvarchar*
> > *Size: 2147483647*
> > *Default: null*
> > *Not Null: false*
> > *Given column:*
> > *Full Name: LafaEntry.originalEntry*
> > *Type: varchar*
> > *Size: 255*
> > *Default: null*
> > *Not Null: false*
> >
> > Does anyone know why this is happening and how I can get rid of the 
> > warnings? Is SQLServer 2005 supported by OpenJPA?
> >
> > BTW, the warnings don't seem to be saved in my log files - 
> they only 
> > appear on stdout. Doesn't seem right to me.
> >
> > /Bengt
> >
> >
> >
> 

No idea if this will work, but did you try:

@Column(columnDefinition = "VARCHAR(2147483647)")

 

John

---- 

Who is General Failure, and why is he reading my hard disk?