-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
1,201 additions
and
0 deletions.
There are no files selected for viewing
623 changes: 623 additions & 0 deletions
623
docs/spring/cs126c9aac-4de8-11ee-a0aa-acde48001122.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Copyright 2009-2018 the original author or authors. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.ibatis.submitted.resultmapwithassociationstest; | ||
|
||
import java.util.List; | ||
|
||
public interface Mapper { | ||
List<Person> findAll(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright 2009-2015 the original author or authors. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.ibatis.submitted.resultmapwithassociationstest; | ||
|
||
import java.util.List; | ||
|
||
public class Person { | ||
private int id; | ||
private List<Address> addresses; | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setId(final int id) { | ||
this.id = id; | ||
} | ||
|
||
public List<Address> getAddresses() { | ||
return addresses; | ||
} | ||
|
||
public void setAddresses(final List<Address> addresses) { | ||
this.addresses = addresses; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* Copyright 2009-2018 the original author or authors. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.ibatis.submitted.constructor_columnprefix; | ||
|
||
public class EntityKey { | ||
private Integer id; | ||
|
||
public Integer getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Integer id) { | ||
this.id = id; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + ((id == null) ? 0 : id.hashCode()); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
EntityKey other = (EntityKey) obj; | ||
if (id == null) { | ||
return other.id == null; | ||
} else return id.equals(other.id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* Copyright 2009-2019 the original author or authors. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.ibatis.type; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
class ObjectTypeHandlerTest extends BaseTypeHandlerTest { | ||
|
||
private static final TypeHandler<Object> TYPE_HANDLER = new ObjectTypeHandler(); | ||
|
||
@Override | ||
@Test | ||
public void shouldSetParameter() throws Exception { | ||
TYPE_HANDLER.setParameter(ps, 1, "Hello", null); | ||
verify(ps).setObject(1, "Hello"); | ||
} | ||
|
||
@Override | ||
@Test | ||
public void shouldGetResultFromResultSetByName() throws Exception { | ||
when(rs.getObject("column")).thenReturn("Hello"); | ||
assertEquals("Hello", TYPE_HANDLER.getResult(rs, "column")); | ||
} | ||
|
||
@Override | ||
@Test | ||
public void shouldGetResultNullFromResultSetByName() throws Exception { | ||
when(rs.getObject("column")).thenReturn(null); | ||
assertNull(TYPE_HANDLER.getResult(rs, "column")); | ||
} | ||
|
||
@Override | ||
@Test | ||
public void shouldGetResultFromResultSetByPosition() throws Exception { | ||
when(rs.getObject(1)).thenReturn("Hello"); | ||
assertEquals("Hello", TYPE_HANDLER.getResult(rs, 1)); | ||
} | ||
|
||
@Override | ||
@Test | ||
public void shouldGetResultNullFromResultSetByPosition() throws Exception { | ||
when(rs.getObject(1)).thenReturn(null); | ||
assertNull(TYPE_HANDLER.getResult(rs, 1)); | ||
} | ||
|
||
@Override | ||
@Test | ||
public void shouldGetResultFromCallableStatement() throws Exception { | ||
when(cs.getObject(1)).thenReturn("Hello"); | ||
assertEquals("Hello", TYPE_HANDLER.getResult(cs, 1)); | ||
} | ||
|
||
@Override | ||
@Test | ||
public void shouldGetResultNullFromCallableStatement() throws Exception { | ||
when(cs.getObject(1)).thenReturn(null); | ||
assertNull(TYPE_HANDLER.getResult(cs, 1)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright 2009-2018 the original author or authors. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.ibatis.submitted.permissions; | ||
|
||
public class Permission { | ||
|
||
private String permission; | ||
private Resource resource; | ||
|
||
public String getPermission() { | ||
return permission; | ||
} | ||
|
||
public void setPermission(String permission) { | ||
this.permission = permission; | ||
} | ||
|
||
public Resource getResource() { | ||
return resource; | ||
} | ||
|
||
public void setResource(Resource resource) { | ||
this.resource = resource; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* Copyright 2009-2019 the original author or authors. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.ibatis.domain.blog; | ||
|
||
public class PostLiteId { | ||
private int id; | ||
|
||
public PostLiteId() { | ||
|
||
} | ||
|
||
public PostLiteId(int aId) { | ||
id = aId; | ||
} | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
|
||
final PostLiteId that = (PostLiteId) o; | ||
|
||
return id == that.id; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return id; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
* Copyright 2009-2019 the original author or authors. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.ibatis.type; | ||
|
||
import java.io.InputStream; | ||
import java.sql.*; | ||
|
||
/** | ||
* The {@link TypeHandler} for {@link Blob}/{@link InputStream} using method supported at JDBC 4.0. | ||
* @since 3.4.0 | ||
* @author Kazuki Shimizu | ||
*/ | ||
public class BlobInputStreamTypeHandler extends BaseTypeHandler<InputStream> { | ||
|
||
/** | ||
* Set an {@link InputStream} into {@link PreparedStatement}. | ||
* @see PreparedStatement#setBlob(int, InputStream) | ||
*/ | ||
@Override | ||
public void setNonNullParameter(PreparedStatement ps, int i, InputStream parameter, JdbcType jdbcType) | ||
throws SQLException { | ||
ps.setBlob(i, parameter); | ||
} | ||
|
||
/** | ||
* Get an {@link InputStream} that corresponds to a specified column name from {@link ResultSet}. | ||
* @see ResultSet#getBlob(String) | ||
*/ | ||
@Override | ||
public InputStream getNullableResult(ResultSet rs, String columnName) | ||
throws SQLException { | ||
return toInputStream(rs.getBlob(columnName)); | ||
} | ||
|
||
/** | ||
* Get an {@link InputStream} that corresponds to a specified column index from {@link ResultSet}. | ||
* @see ResultSet#getBlob(int) | ||
*/ | ||
@Override | ||
public InputStream getNullableResult(ResultSet rs, int columnIndex) | ||
throws SQLException { | ||
return toInputStream(rs.getBlob(columnIndex)); | ||
} | ||
|
||
/** | ||
* Get an {@link InputStream} that corresponds to a specified column index from {@link CallableStatement}. | ||
* @see CallableStatement#getBlob(int) | ||
*/ | ||
@Override | ||
public InputStream getNullableResult(CallableStatement cs, int columnIndex) | ||
throws SQLException { | ||
return toInputStream(cs.getBlob(columnIndex)); | ||
} | ||
|
||
private InputStream toInputStream(Blob blob) throws SQLException { | ||
if (blob == null) { | ||
return null; | ||
} else { | ||
return blob.getBinaryStream(); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.