#367 - Fixes broken JDBC examples.
Adapted all SQL to new default NamingStrategy. See also: DATAJDBC-207.
This commit is contained in:
@@ -68,15 +68,15 @@ public class AggregateConfiguration {
|
||||
public NamingStrategy namingStrategy() {
|
||||
|
||||
Map<String, String> tableAliases = new HashMap<String, String>();
|
||||
tableAliases.put("Manual", "Handbuch");
|
||||
tableAliases.put("manual", "handbuch");
|
||||
|
||||
Map<String, String> columnAliases = new HashMap<String, String>();
|
||||
columnAliases.put("LegoSet.intMaximumAge", "maxAge");
|
||||
columnAliases.put("LegoSet.intMinimumAge", "minAge");
|
||||
columnAliases.put("Handbuch.id", "Handbuch_id");
|
||||
columnAliases.put("lego_set.int_maximum_age", "max_age");
|
||||
columnAliases.put("lego_set.int_minimum_age", "min_age");
|
||||
columnAliases.put("handbuch.id", "handbuch_id");
|
||||
|
||||
Map<String, String> reverseColumnAliases = new HashMap<String, String>();
|
||||
reverseColumnAliases.put("manual", "Handbuch_id");
|
||||
reverseColumnAliases.put("manual", "handbuch_id");
|
||||
|
||||
Map<String, String> keyColumnAliases = new HashMap<String, String>();
|
||||
keyColumnAliases.put("models", "name");
|
||||
|
||||
@@ -29,11 +29,11 @@ import java.util.List;
|
||||
*/
|
||||
interface LegoSetRepository extends CrudRepository<LegoSet, Integer> {
|
||||
|
||||
@Query("SELECT m.name modelName, m.description, l.name setName" +
|
||||
@Query("SELECT m.name model_name, m.description, l.name set_name" +
|
||||
" FROM model m" +
|
||||
" JOIN LegoSet l" +
|
||||
" ON m.legoset = l.id" +
|
||||
" WHERE :age BETWEEN l.minAge and l.maxAge")
|
||||
" JOIN lego_set l" +
|
||||
" ON m.lego_set = l.id" +
|
||||
" WHERE :age BETWEEN l.min_age and l.max_age")
|
||||
List<ModelReport> reportModelForAge(@Param("age") int age);
|
||||
|
||||
@Modifying
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
CREATE TABLE IF NOT EXISTS category (id INTEGER IDENTITY PRIMARY KEY, name VARCHAR(100), description VARCHAR(2000), agegroup VARCHAR(20), created DATETIME, inserted BIGINT);
|
||||
CREATE TABLE IF NOT EXISTS category (id INTEGER IDENTITY PRIMARY KEY, name VARCHAR(100), description VARCHAR(2000), age_group VARCHAR(20), created DATETIME, inserted BIGINT);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS LegoSet (id INTEGER, name VARCHAR(100), minAge INTEGER, maxAge INTEGER);
|
||||
CREATE TABLE IF NOT EXISTS Lego_Set (id INTEGER, name VARCHAR(100), min_Age INTEGER, max_Age INTEGER);
|
||||
CREATE TABLE IF NOT EXISTS Handbuch (handbuch_id INTEGER, author CHAR(100), text CLOB);
|
||||
CREATE TABLE IF NOT EXISTS Model (name VARCHAR(100), description CLOB, legoset INTEGER);
|
||||
CREATE TABLE IF NOT EXISTS Model (name VARCHAR(100), description CLOB, lego_set INTEGER);
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
<select id="findAllByProperty-models" resultType="ModelMapEntry" parameterType="org.springframework.data.jdbc.mybatis.MyBatisContext">
|
||||
SELECT name, description
|
||||
FROM Model
|
||||
WHERE legoset = #{id}
|
||||
WHERE lego_set = #{id}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -2,7 +2,7 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="example.springdata.jdbc.mybatis.ModelMapper">
|
||||
<insert id="insert" parameterType="org.springframework.data.jdbc.mybatis.MyBatisContext">
|
||||
<bind name="parentId" value="_parameter.get('LegoSet')" />
|
||||
INSERT INTO Model (name, description, legoset) VALUES (#{instance.name}, #{instance.description}, #{parentId})
|
||||
<bind name="parentId" value="_parameter.get('lego_set')" />
|
||||
INSERT INTO Model (name, description, lego_set) VALUES (#{instance.name}, #{instance.description}, #{parentId})
|
||||
</insert>
|
||||
</mapper>
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
CREATE TABLE IF NOT EXISTS LegoSet (
|
||||
CREATE TABLE IF NOT EXISTS lego_set (
|
||||
id INTEGER IDENTITY PRIMARY KEY,
|
||||
name VARCHAR(100)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS manual (
|
||||
id INTEGER IDENTITY PRIMARY KEY,
|
||||
LegoSet INTEGER,
|
||||
lego_set INTEGER,
|
||||
author CHAR(100),
|
||||
text VARCHAR(1000)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS Model (
|
||||
name VARCHAR(100),
|
||||
description CLOB,
|
||||
legoset INTEGER
|
||||
lego_set INTEGER
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user