Comments (13)
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.
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.
@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.
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.
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.
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.
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.
Original comment by eduardo.macarron
on 23 Jul 2011 at 12:59
Attachments:
from mybatis.
Another try with less code changes.
Original comment by eduardo.macarron
on 30 Aug 2011 at 4:47
Attachments:
from mybatis.
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.
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.
Original comment by eduardo.macarron
on 3 Mar 2012 at 9:11
- Added labels: Version-Release3.x
from mybatis.
Original comment by eduardo.macarron
on 3 Mar 2012 at 9:37
from mybatis.
Related Issues (20)
- [mybatis-spring] Mapper scanning should not rely on proprietary @Mapper annotation HOT 1
- Migrations archive unzips to "ibatis-migrations" instead of "mybatis-migrations" HOT 2
- OSGI Support HOT 4
- Remove mapper order restriction when referencing SQL fragment in another file. HOT 40
- Non-existent object id is incorrectly resolved when there is an entry with the same short name. HOT 13
- Allow applying @Transactional to types and interfaces and add a @NoTransaction attribute HOT 4
- Please prioritize issues HOT 1
- Adjust issue's status HOT 1
- Unable to get auto-generated ID with mysql using annotations HOT 1
- Mybatis-spring doesn't propagate exceptions up the stack when using batch mode HOT 17
- how to free temp tablespace allocated for a select stmt return parameter HOT 1
- rollback on BatchExecutor executes batched statements HOT 8
- resultMap doesn't support mapping of unnamed columns by index HOT 2
- mybatis3.0.3 bug in WebService ?? HOT 2
- Annotation-based and AOP-based sessions HOT 3
- Global parameter typeHandler not invoked in case of null values HOT 2
- Exception: Result Maps collection does not contain value for test.User-result HOT 2
- Handling of update counts before result sets in select HOT 8
- configure behavior when all columns values are null for some rows HOT 5
- queryForMap does not use a column as map HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mybatis.