Skip to content

Commit 05b6dc6

Browse files
committed
エンティティクラスの継承構造が2段階の場合に無限ループが発生する不具合を修正
2段階とは、親、子、孫のように3つのクラスからなる継承構造を意味します。 close #163
1 parent cf6141f commit 05b6dc6

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

src/main/java/org/seasar/doma/internal/jdbc/entity/PropertyField.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ private Field getField(Class<?> clazz, String name) {
6767
}
6868

6969
private Field findField(Class<?> clazz, String name) {
70-
for (Class<?> cl = clazz; cl != Object.class; cl = clazz
71-
.getSuperclass()) {
70+
for (Class<?> cl = clazz; cl != Object.class; cl = cl.getSuperclass()) {
7271
try {
7372
return cl.getDeclaredField(name);
7473
} catch (NoSuchFieldException ignored) {

src/test/java/org/seasar/doma/internal/jdbc/entity/Animal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @author nakamura-to
2020
*
2121
*/
22-
public class Animal {
22+
public class Animal extends Life {
2323

2424
public String kind;
2525
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2004-2010 the Seasar Foundation and the Others.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13+
* either express or implied. See the License for the specific language
14+
* governing permissions and limitations under the License.
15+
*/
16+
package org.seasar.doma.internal.jdbc.entity;
17+
18+
/**
19+
* @author nakamura-to
20+
*
21+
*/
22+
public class Life {
23+
24+
int weight;
25+
}

src/test/java/org/seasar/doma/internal/jdbc/entity/PropertyFieldTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ public void testConstructor_parentPath() throws Exception {
3232
assertEquals(1, path.fields.size());
3333
}
3434

35+
public void testConstructor_grandParentPath() throws Exception {
36+
PropertyField<Person> path = new PropertyField<>("weight", Person.class);
37+
assertEquals(1, path.fields.size());
38+
}
39+
3540
public void testConstructor_nestedPath() throws Exception {
3641
PropertyField<Person> path = new PropertyField<>("address.city",
3742
Person.class);

0 commit comments

Comments
 (0)