Skip to content

Provide a naming strategy for Mybatis method/statement names. [DATAJDBC-418] #639

Open
@spring-projects-issues

Description

@spring-projects-issues

Tyler K Van Gorder opened DATAJDBC-418 and commented

In our traditional Mybatis applications, we had a common pattern where our DataAcccess objects were co-located with our Mapper Interfaces & any associated Mapper.xml files: 

As an example, if "AttributeDefinition" is the aggregate root:

com.example.model.attribute:
  AttributeDefinition
  UnitOfMeasure
  AttributeDefinitionEnumeratedValue

And the data access for all three of those domain types ends up looking like this: 

 

com.example.dao.attribute: 

  AttributeDefinitionDao.java
  AttributeDefinitionDaoImpl.java
  AttributeDefinitionMapper.java
  AttributeDefinitionMapper.xml

And the mapper has queries for the aggregate root AND its associated domain types.

 

I am prototyping some work with Spring Data JDBC + Mybatis and I would like to group the mappers with the repository that is ultimately going to be using those mappers:

com.example.dao.attribute

  AttributeDefinitionRepository.java
  AttributeDefinitionMapper.java
  AttributeDefinitionMapper.xml
  

Where the queries for all domain types connected to the aggregate root are in the same mapper. 

I can use the NamespaceStrategy to map a domain type into the correct namespace, however, the statements are hard-coded and assume each domain type is mapped one-to-one with a corresponding mapper. 

Can we expand the NamespaceStrategy such that it can be passed both the domain type AND the method name?

Another really nice feature would be to have an out-of-the-box configuration strategy (annotation-based or Spring environment-based) that can be used to map a domain type to a Mybatis mapper namespace.

 


Affects: 1.1 RC3 (Moore)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions