Skip to content

Commit f23202b

Browse files
author
Jarvis Song
authored
Merge pull request #100 from hatunet/dev
release 1.0.8
2 parents 3b6fba0 + 1486b3b commit f23202b

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Download the jar through Maven:
3535
<dependency>
3636
<groupId>com.ifrabbit</groupId>
3737
<artifactId>spring-data-mybatis</artifactId>
38-
<version>1.0.7.RELEASE</version>
38+
<version>1.0.8.RELEASE</version>
3939
</dependency>
4040
```
4141

@@ -44,7 +44,7 @@ If you want use snapshot version , you can download the jar through maven:
4444
<dependency>
4545
<groupId>com.ifrabbit</groupId>
4646
<artifactId>spring-data-mybatis</artifactId>
47-
<version>1.0.8.BUILD-SNAPSHOT</version>
47+
<version>1.0.9.BUILD-SNAPSHOT</version>
4848
</dependency>
4949
```
5050

@@ -150,7 +150,7 @@ add the jar through Maven:
150150
<dependency>
151151
<groupId>com.ifrabbit</groupId>
152152
<artifactId>spring-boot-starter-data-mybatis</artifactId>
153-
<version>1.0.7.RELEASE</version>
153+
<version>1.0.8.RELEASE</version>
154154
</dependency>
155155
```
156156

README_zh.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Spring Data 项目的主要目标是使构建使用数据访问技术的 Spring
3434
<dependency>
3535
<groupId>com.ifrabbit</groupId>
3636
<artifactId>spring-data-mybatis</artifactId>
37-
<version>1.0.7.RELEASE</version>
37+
<version>1.0.8.RELEASE</version>
3838
</dependency>
3939
```
4040

@@ -43,7 +43,7 @@ Spring Data 项目的主要目标是使构建使用数据访问技术的 Spring
4343
<dependency>
4444
<groupId>com.ifrabbit</groupId>
4545
<artifactId>spring-data-mybatis</artifactId>
46-
<version>1.0.8.BUILD-SNAPSHOT</version>
46+
<version>1.0.9.BUILD-SNAPSHOT</version>
4747
</dependency>
4848
```
4949
使用快照版本前,需要在pom.xml中配置:
@@ -150,7 +150,7 @@ public class UserRepositoryIntegrationTest {
150150
<dependency>
151151
<groupId>com.ifrabbit</groupId>
152152
<artifactId>spring-boot-starter-data-mybatis</artifactId>
153-
<version>1.0.7.RELEASE</version>
153+
<version>1.0.8.RELEASE</version>
154154
</dependency>
155155
```
156156

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<groupId>com.ifrabbit</groupId>
1313
<artifactId>spring-data-mybatis</artifactId>
14-
<version>1.0.8.BUILD-SNAPSHOT</version>
14+
<version>1.0.8.RELEASE</version>
1515

1616
<name>Spring Data MyBatis</name>
1717
<description>The primary goal of the Spring Data project is to make it easier to build Spring-powered applications

src/main/java/org/springframework/data/mybatis/repository/query/PartTreeMybatisQuery.java

+20-4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.slf4j.Logger;
2525
import org.slf4j.LoggerFactory;
2626
import org.springframework.data.mapping.Association;
27+
import org.springframework.data.mapping.PropertyPath;
2728
import org.springframework.data.mapping.model.MappingException;
2829
import org.springframework.data.mybatis.mapping.*;
2930
import org.springframework.data.mybatis.repository.dialect.Dialect;
@@ -126,11 +127,26 @@ private String buildQueryCondition(boolean basic) {
126127
Association<MybatisPersistentProperty> ass = property.getAssociation();
127128
if (ass instanceof MybatisManyToOneAssociation) {
128129
MybatisManyToOneAssociation association = (MybatisManyToOneAssociation) ass;
129-
MybatisPersistentProperty leafProperty = association.getObversePersistentEntity().getPersistentProperty(part.getProperty().getLeafProperty().getSegment());
130-
if (null == leafProperty) {
131-
throw new MybatisQueryException("can not find property: " + part.getProperty().getLeafProperty().getSegment() + " from entity: " + association.getObversePersistentEntity().getName());
130+
131+
MybatisPersistentEntity<?> obversePersistentEntity = association.getObversePersistentEntity();
132+
if (null == obversePersistentEntity) {
133+
throw new MybatisQueryException("can not find obverse persistent entity.");
134+
}
135+
136+
PropertyPath leaf = part.getProperty().getLeafProperty();
137+
138+
if (obversePersistentEntity.getType() == leaf.getType()) {
139+
140+
//columnName = quota(persistentEntity.getEntityName() + "." + part.getProperty().getSegment()) + "." + dialect.wrapColumnName(obversePersistentEntity.getIdProperty().getColumnName());
141+
throw new UnsupportedOperationException("findBy{Association Model} Style is not support now.");
142+
143+
} else {
144+
MybatisPersistentProperty leafProperty = obversePersistentEntity.getPersistentProperty(leaf.getSegment());
145+
if (null == leafProperty) {
146+
throw new MybatisQueryException("can not find property: " + leaf.getSegment() + " from entity: " + obversePersistentEntity.getName());
147+
}
148+
columnName = quota(persistentEntity.getEntityName() + "." + part.getProperty().getSegment()) + "." + dialect.wrapColumnName(leafProperty.getColumnName());
132149
}
133-
columnName = quota(persistentEntity.getEntityName() + "." + part.getProperty().getSegment()) + "." + dialect.wrapColumnName(leafProperty.getColumnName());
134150
} else if (ass instanceof MybatisEmbeddedAssociation) {
135151
columnName = quota(persistentEntity.getEntityName()) + "." + dialect.wrapColumnName(ass.getObverse().getColumnName());
136152
}

0 commit comments

Comments
 (0)