Quantcast

updateByExample(Selective) is using the alias of the table which will not work in postgresql

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

updateByExample(Selective) is using the alias of the table which will not work in postgresql

Johan Compagner
I have seen more post for this (many 2009 or 2010), but i am using the
latest generated code in eclipse (i think 1.31)

i have this:

<table schema="public" tableName="card" alias="card">

that will generate update statements, but only the by example onces
not the one with the primairy key

 <update id="updateByExample" parameterType="map">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do
not modify.
      This element was generated on Mon Feb 20 23:34:23 CET 2012.
    -->
    update public.card card
    set card.card_id =
#{record.cardId,jdbcType=OTHER,typeHandler=com.loial.db.UuidTypeHandler},

and that set card.card_id doesn't work for postgresql:

ERROR:  column "card" of relation "card" does not exist
LINE 1: update "public"."card" card SET card."active" = true WHERE
(...
                                        ^

********** Error **********

ERROR: column "card" of relation "card" does not exist
SQL state: 42703
Character: 33

How can i make sure that it never generates this?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: updateByExample(Selective) is using the alias of the table which will not work in postgresql

Jeff Butler
Right now you have to remove the alias from the <table> element - or go manually change the generated SQL. 

Jeff Butler

On Monday, February 20, 2012, Johan Compagner wrote:
I have seen more post for this (many 2009 or 2010), but i am using the
latest generated code in eclipse (i think 1.31)

i have this:

<table schema="public" tableName="card" alias="card">

that will generate update statements, but only the by example onces
not the one with the primairy key

 <update id="updateByExample" parameterType="map">
   <!--
     WARNING - @mbggenerated
     This element is automatically generated by MyBatis Generator, do
not modify.
     This element was generated on Mon Feb 20 23:34:23 CET 2012.
   -->
   update public.card card
   set card.card_id =
#{record.cardId,jdbcType=OTHER,typeHandler=com.loial.db.UuidTypeHandler},

and that set card.card_id doesn't work for postgresql:

ERROR:  column "card" of relation "card" does not exist
LINE 1: update "public"."card" card SET card."active" = true WHERE
(...
                                       ^

********** Error **********

ERROR: column "card" of relation "card" does not exist
SQL state: 42703
Character: 33

How can i make sure that it never generates this?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: updateByExample(Selective) is using the alias of the table which will not work in postgresql

Johan Compagner
Thx Jeff,

the thing is i use also the auto generated select column includes in various own selects statements that have joins and so on, so i need to prefix it for those
Or i have to do that myself and keep that up to date with the latest columns...

Any fix on the horizon?

johan


On Tue, Feb 21, 2012 at 18:27, Jeff Butler <[hidden email]> wrote:
Right now you have to remove the alias from the <table> element - or go manually change the generated SQL. 

Jeff Butler


On Monday, February 20, 2012, Johan Compagner wrote:
I have seen more post for this (many 2009 or 2010), but i am using the
latest generated code in eclipse (i think 1.31)

i have this:

<table schema="public" tableName="card" alias="card">

that will generate update statements, but only the by example onces
not the one with the primairy key

 <update id="updateByExample" parameterType="map">
   <!--
     WARNING - @mbggenerated
     This element is automatically generated by MyBatis Generator, do
not modify.
     This element was generated on Mon Feb 20 23:34:23 CET 2012.
   -->
   update public.card card
   set card.card_id =
#{record.cardId,jdbcType=OTHER,typeHandler=com.loial.db.UuidTypeHandler},

and that set card.card_id doesn't work for postgresql:

ERROR:  column "card" of relation "card" does not exist
LINE 1: update "public"."card" card SET card."active" = true WHERE
(...
                                       ^

********** Error **********

ERROR: column "card" of relation "card" does not exist
SQL state: 42703
Character: 33

How can i make sure that it never generates this?

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: updateByExample(Selective) is using the alias of the table which will not work in postgresql

Johan Compagner
If i look at the code then UpdateByPrimaryKeySelectiveElementGenerator does this:

   sb.append(MyBatis3FormattingUtilities
                    .getEscapedColumnName(introspectedColumn));


but UpdateByExampleSelectiveElementGenerator does this:

            sb.append(MyBatis3FormattingUtilities
                    .getAliasedEscapedColumnName(introspectedColumn));

when generating the set column = x

what is the reason for this difference?

Searching on the internet there seem to be more then one database that can't handle this

johan

On Tue, Feb 21, 2012 at 22:00, Johan Compagner <[hidden email]> wrote:
Thx Jeff,

the thing is i use also the auto generated select column includes in various own selects statements that have joins and so on, so i need to prefix it for those
Or i have to do that myself and keep that up to date with the latest columns...

Any fix on the horizon?

johan



On Tue, Feb 21, 2012 at 18:27, Jeff Butler <[hidden email]> wrote:
Right now you have to remove the alias from the <table> element - or go manually change the generated SQL. 

Jeff Butler


On Monday, February 20, 2012, Johan Compagner wrote:
I have seen more post for this (many 2009 or 2010), but i am using the
latest generated code in eclipse (i think 1.31)

i have this:

<table schema="public" tableName="card" alias="card">

that will generate update statements, but only the by example onces
not the one with the primairy key

 <update id="updateByExample" parameterType="map">
   <!--
     WARNING - @mbggenerated
     This element is automatically generated by MyBatis Generator, do
not modify.
     This element was generated on Mon Feb 20 23:34:23 CET 2012.
   -->
   update public.card card
   set card.card_id =
#{record.cardId,jdbcType=OTHER,typeHandler=com.loial.db.UuidTypeHandler},

and that set card.card_id doesn't work for postgresql:

ERROR:  column "card" of relation "card" does not exist
LINE 1: update "public"."card" card SET card."active" = true WHERE
(...
                                       ^

********** Error **********

ERROR: column "card" of relation "card" does not exist
SQL state: 42703
Character: 33

How can i make sure that it never generates this?


Loading...