MyBatis Generator - Add Prefix to Table's Field Name

90 views
Skip to first unread message

Muhammad Edwin

unread,
May 9, 2013, 12:12:33 PM5/9/13
to mybati...@googlegroups.com
Good day mates,

i wonder, does MyBatis Generator have the ability to add prefix to property names,
because today i have  a weird case,
i had to create java mappings from a very weird database using MBG
it have a dozen tables, each have dozens of weird fields, such as "11", "12", "13"

below is the sql example of one table,
CREATE TABLE `x11` (
  `Id` int(11) NOT NULL AUTOINCREMENT,  
  `11` varchar(255) DEFAULT NULL,
  `12` varchar(255) DEFAULT NULL,
  `21` varchar(255) DEFAULT NULL,
  `22` varchar(255) DEFAULT NULL
)
when i generate the java class, it shows error on my IDE due to java variables arent permitted to use "11" as its variable name.
im aware MBG have the columnOverride property to override the mapping of field names to java property,
but mapping each field using columnOverride one by one is very error prone

perhaps MBG has a much elegant way of dealing with this kind of fields,
thank you for your attention.

--
Regards,


edwin.
"It's Not the Big That Eat the Small... It's the Fast That Eat the Slow"

Jeff Butler

unread,
May 9, 2013, 12:22:16 PM5/9/13
to mybati...@googlegroups.com


--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Muhammad Edwin

unread,
May 9, 2013, 12:27:41 PM5/9/13
to mybati...@googlegroups.com

Thanks Jeff, it works like a charm.



On Thu, May 9, 2013 at 11:22 PM, Jeff Butler <jeffg...@gmail.com> wrote:



Reply all
Reply to author
Forward
0 new messages