Giter VIP home page Giter VIP logo

Comments (13)

GoogleCodeExporter avatar GoogleCodeExporter commented on September 26, 2024
Actually, it seems like the change can be easily applied in 
Reflector.findPropertyName()

Original comment by [email protected] on 13 Jun 2010 at 2:17

from mybatis.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 26, 2024
Acutally, ibator v1.2.1 implement mapping table column to POJO property use 
org.apache.ibatis.ibator.internal.util.JavaBeamUtil.getCamelCaseString method, 
trim the char in "_-$@# ", for example: column "THE_FIRST-FIELD" will be 
convert to property name "theFirstField".

Original comment by [email protected] on 28 Jun 2010 at 8:52

from mybatis.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 26, 2024
@myweboffice:
ok, that's cool and solves half of the problem. So why not use that method 
inside Reflector.findPropertyName() ?
I think that could work without efffort.

Ideally, I think it would be more flexible if MyBatis could let you inject a 
class of your own that handles custom column-to-field mapping, but the fact 
that the Reflector class uses static methods constraints this.

Original comment by [email protected] on 28 Jun 2010 at 2:20

from mybatis.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 26, 2024
Would a simple solution like this be appropriate for just the underscore 
mapping of field_name > fieldName?

Reflector.findPropertyName():

  public String findPropertyName(String name) {
      String upperName = name.toUpperCase(Locale.ENGLISH);
      return caseInsensitivePropertyMap.containsKey(upperName) ?
             caseInsensitivePropertyMap.get(upperName) :
             caseInsensitivePropertyMap.get(upperName.replaceAll("_", ""));
  }

Original comment by [email protected] on 14 Jul 2010 at 3:52

from mybatis.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 26, 2024
I think, implementing this feature should be assigned a higher priority, because

1) Using column names without underscores in databases that convert all column 
names to lower case leads to almost unreadable column names.

2) Hibernate uses the mapping between camelCase fields and underscore separated 
column names by default. So it's very inconvenient to switch between Hibernate 
and MyBatis at the moment (either rename all the columns, or manually add all 
the column name mappings in the MyBatis SQL Map XML files).

Original comment by chris.lercher on 16 Jun 2011 at 10:35

from mybatis.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 26, 2024
Seems an easy change. It could break backwards compatibility (very unlikely) so 
maybe a general property should be added.

Patch attached.

Original comment by eduardo.macarron on 23 Jul 2011 at 12:51

Attachments:

from mybatis.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 26, 2024
Sorry, that patch has unwanted changes, this is the right one

Original comment by eduardo.macarron on 23 Jul 2011 at 12:55

from mybatis.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 26, 2024

Original comment by eduardo.macarron on 23 Jul 2011 at 12:59

Attachments:

from mybatis.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 26, 2024
Another try with less code changes. 

Original comment by eduardo.macarron on 30 Aug 2011 at 4:47

Attachments:

from mybatis.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 26, 2024
Patch applied in r3895. 

Added a new property named mapUnderscoreToCamelCase that defaults to false.
Please give it a try and post your feedback (here or in users ML).

We will update the manual once the change is released.

Original comment by eduardo.macarron on 7 Sep 2011 at 8:58

  • Changed state: Fixed
  • Added labels: Target-Release3.0.6, Component-SqlMaps

from mybatis.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 26, 2024
I am afraid this last fix is too simple :) Maps do not work properly. 

That should be fixed now in r3896

Original comment by eduardo.macarron on 8 Sep 2011 at 6:02

from mybatis.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 26, 2024

Original comment by eduardo.macarron on 3 Mar 2012 at 9:11

  • Added labels: Version-Release3.x

from mybatis.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 26, 2024

Original comment by eduardo.macarron on 3 Mar 2012 at 9:37

from mybatis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.