Skip to content

Commit 981c659

Browse files
querydsl-maven-pluginによるjavaコードの自動生成先をtarget配下ではなくsrc/generated配下に変更(他と合わせる)
1 parent 85b312b commit 981c659

File tree

9 files changed

+446
-4
lines changed

9 files changed

+446
-4
lines changed

demo-querydsl/pom.xml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
</configuration>
7373
<executions>
7474
<execution>
75-
<id>create-db</id>
75+
<id>create-db-for-code-generation</id>
7676
<phase>process-resources</phase>
7777
<goals>
7878
<goal>execute</goal>
@@ -86,14 +86,12 @@
8686
<basedir>${basedir}/src/main/resources/</basedir>
8787
<includes>
8888
<include>schema.sql</include>
89-
<include>data.sql</include>
9089
</includes>
9190
</fileset>
9291
</configuration>
9392
</execution>
9493
</executions>
9594
</plugin>
96-
9795
<plugin>
9896
<groupId>com.querydsl</groupId>
9997
<artifactId>querydsl-maven-plugin</artifactId>
@@ -117,7 +115,8 @@
117115
</beanInterfaces>
118116
<beanAddToString>true</beanAddToString>
119117
<exportBeans>true</exportBeans>
120-
<targetFolder>${project.basedir}/target/generated-sources/java</targetFolder>
118+
<!--<targetFolder>${project.basedir}/target/generated-sources/java</targetFolder>-->
119+
<targetFolder>${project.basedir}/src/generated/java</targetFolder>
121120
</configuration>
122121
<dependencies>
123122
<dependency>
@@ -127,6 +126,23 @@
127126
</dependency>
128127
</dependencies>
129128
</plugin>
129+
<plugin>
130+
<groupId>org.codehaus.mojo</groupId>
131+
<artifactId>build-helper-maven-plugin</artifactId>
132+
<executions>
133+
<execution>
134+
<phase>process-resources</phase>
135+
<goals>
136+
<goal>add-source</goal>
137+
</goals>
138+
<configuration>
139+
<sources>
140+
<source>src/generated/java</source>
141+
</sources>
142+
</configuration>
143+
</execution>
144+
</executions>
145+
</plugin>
130146
<plugin>
131147
<groupId>org.springframework.boot</groupId>
132148
<artifactId>spring-boot-maven-plugin</artifactId>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.example.querydsl;
2+
3+
import javax.annotation.Generated;
4+
import java.io.Serializable;
5+
6+
/**
7+
* Base is a Querydsl bean type
8+
*/
9+
@Generated("com.querydsl.codegen.BeanSerializer")
10+
public class Base implements Serializable {
11+
12+
private Long id;
13+
14+
private String name;
15+
16+
public Long getId() {
17+
return id;
18+
}
19+
20+
public void setId(Long id) {
21+
this.id = id;
22+
}
23+
24+
public String getName() {
25+
return name;
26+
}
27+
28+
public void setName(String name) {
29+
this.name = name;
30+
}
31+
32+
@Override
33+
public String toString() {
34+
return "id = " + id + ", name = " + name;
35+
}
36+
37+
}
38+
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.example.querydsl;
2+
3+
import javax.annotation.Generated;
4+
import java.io.Serializable;
5+
6+
/**
7+
* Pizza is a Querydsl bean type
8+
*/
9+
@Generated("com.querydsl.codegen.BeanSerializer")
10+
public class Pizza implements Serializable {
11+
12+
private Long baseId;
13+
14+
private Long id;
15+
16+
private String name;
17+
18+
private java.math.BigDecimal price;
19+
20+
public Long getBaseId() {
21+
return baseId;
22+
}
23+
24+
public void setBaseId(Long baseId) {
25+
this.baseId = baseId;
26+
}
27+
28+
public Long getId() {
29+
return id;
30+
}
31+
32+
public void setId(Long id) {
33+
this.id = id;
34+
}
35+
36+
public String getName() {
37+
return name;
38+
}
39+
40+
public void setName(String name) {
41+
this.name = name;
42+
}
43+
44+
public java.math.BigDecimal getPrice() {
45+
return price;
46+
}
47+
48+
public void setPrice(java.math.BigDecimal price) {
49+
this.price = price;
50+
}
51+
52+
@Override
53+
public String toString() {
54+
return "baseId = " + baseId + ", id = " + id + ", name = " + name + ", price = " + price;
55+
}
56+
57+
}
58+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.example.querydsl;
2+
3+
import javax.annotation.Generated;
4+
import java.io.Serializable;
5+
6+
/**
7+
* PizzaToppings is a Querydsl bean type
8+
*/
9+
@Generated("com.querydsl.codegen.BeanSerializer")
10+
public class PizzaToppings implements Serializable {
11+
12+
private Long pizzaId;
13+
14+
private Long toppingsId;
15+
16+
public Long getPizzaId() {
17+
return pizzaId;
18+
}
19+
20+
public void setPizzaId(Long pizzaId) {
21+
this.pizzaId = pizzaId;
22+
}
23+
24+
public Long getToppingsId() {
25+
return toppingsId;
26+
}
27+
28+
public void setToppingsId(Long toppingsId) {
29+
this.toppingsId = toppingsId;
30+
}
31+
32+
@Override
33+
public String toString() {
34+
return "pizzaId = " + pizzaId + ", toppingsId = " + toppingsId;
35+
}
36+
37+
}
38+
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.example.querydsl;
2+
3+
import static com.querydsl.core.types.PathMetadataFactory.*;
4+
5+
import com.querydsl.core.types.dsl.*;
6+
7+
import com.querydsl.core.types.PathMetadata;
8+
import javax.annotation.Generated;
9+
import com.querydsl.core.types.Path;
10+
11+
import com.querydsl.sql.ColumnMetadata;
12+
import java.sql.Types;
13+
14+
15+
16+
17+
/**
18+
* QBase is a Querydsl query type for Base
19+
*/
20+
@Generated("com.querydsl.sql.codegen.MetaDataSerializer")
21+
public class QBase extends com.querydsl.sql.RelationalPathBase<Base> {
22+
23+
private static final long serialVersionUID = 1229658905;
24+
25+
public static final QBase base = new QBase("BASE");
26+
27+
public final NumberPath<Long> id = createNumber("id", Long.class);
28+
29+
public final StringPath name = createString("name");
30+
31+
public final com.querydsl.sql.PrimaryKey<Base> constraint1 = createPrimaryKey(id);
32+
33+
public final com.querydsl.sql.ForeignKey<Pizza> _fkm6kai6c5evr38duyfh06ue29u = createInvForeignKey(id, "BASE_ID");
34+
35+
public QBase(String variable) {
36+
super(Base.class, forVariable(variable), "PUBLIC", "BASE");
37+
addMetadata();
38+
}
39+
40+
public QBase(String variable, String schema, String table) {
41+
super(Base.class, forVariable(variable), schema, table);
42+
addMetadata();
43+
}
44+
45+
public QBase(Path<? extends Base> path) {
46+
super(path.getType(), path.getMetadata(), "PUBLIC", "BASE");
47+
addMetadata();
48+
}
49+
50+
public QBase(PathMetadata metadata) {
51+
super(Base.class, metadata, "PUBLIC", "BASE");
52+
addMetadata();
53+
}
54+
55+
public void addMetadata() {
56+
addMetadata(id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull());
57+
addMetadata(name, ColumnMetadata.named("NAME").withIndex(2).ofType(Types.VARCHAR).withSize(255));
58+
}
59+
60+
}
61+
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package com.example.querydsl;
2+
3+
import static com.querydsl.core.types.PathMetadataFactory.*;
4+
5+
import com.querydsl.core.types.dsl.*;
6+
7+
import com.querydsl.core.types.PathMetadata;
8+
import javax.annotation.Generated;
9+
import com.querydsl.core.types.Path;
10+
11+
import com.querydsl.sql.ColumnMetadata;
12+
import java.sql.Types;
13+
14+
15+
16+
17+
/**
18+
* QPizza is a Querydsl query type for Pizza
19+
*/
20+
@Generated("com.querydsl.sql.codegen.MetaDataSerializer")
21+
public class QPizza extends com.querydsl.sql.RelationalPathBase<Pizza> {
22+
23+
private static final long serialVersionUID = -522104512;
24+
25+
public static final QPizza pizza = new QPizza("PIZZA");
26+
27+
public final NumberPath<Long> baseId = createNumber("baseId", Long.class);
28+
29+
public final NumberPath<Long> id = createNumber("id", Long.class);
30+
31+
public final StringPath name = createString("name");
32+
33+
public final NumberPath<java.math.BigDecimal> price = createNumber("price", java.math.BigDecimal.class);
34+
35+
public final com.querydsl.sql.PrimaryKey<Pizza> constraint4 = createPrimaryKey(id);
36+
37+
public final com.querydsl.sql.ForeignKey<Base> fkm6kai6c5evr38duyfh06ue29u = createForeignKey(baseId, "ID");
38+
39+
public final com.querydsl.sql.ForeignKey<PizzaToppings> _fk78l5qtferc9qhfkkgyv99lmst = createInvForeignKey(id, "PIZZA_ID");
40+
41+
public QPizza(String variable) {
42+
super(Pizza.class, forVariable(variable), "PUBLIC", "PIZZA");
43+
addMetadata();
44+
}
45+
46+
public QPizza(String variable, String schema, String table) {
47+
super(Pizza.class, forVariable(variable), schema, table);
48+
addMetadata();
49+
}
50+
51+
public QPizza(Path<? extends Pizza> path) {
52+
super(path.getType(), path.getMetadata(), "PUBLIC", "PIZZA");
53+
addMetadata();
54+
}
55+
56+
public QPizza(PathMetadata metadata) {
57+
super(Pizza.class, metadata, "PUBLIC", "PIZZA");
58+
addMetadata();
59+
}
60+
61+
public void addMetadata() {
62+
addMetadata(baseId, ColumnMetadata.named("BASE_ID").withIndex(4).ofType(Types.BIGINT).withSize(19));
63+
addMetadata(id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull());
64+
addMetadata(name, ColumnMetadata.named("NAME").withIndex(2).ofType(Types.VARCHAR).withSize(255));
65+
addMetadata(price, ColumnMetadata.named("PRICE").withIndex(3).ofType(Types.DECIMAL).withSize(19).withDigits(2));
66+
}
67+
68+
}
69+
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package com.example.querydsl;
2+
3+
import static com.querydsl.core.types.PathMetadataFactory.*;
4+
5+
import com.querydsl.core.types.dsl.*;
6+
7+
import com.querydsl.core.types.PathMetadata;
8+
import javax.annotation.Generated;
9+
import com.querydsl.core.types.Path;
10+
11+
import com.querydsl.sql.ColumnMetadata;
12+
import java.sql.Types;
13+
14+
15+
16+
17+
/**
18+
* QPizzaToppings is a Querydsl query type for PizzaToppings
19+
*/
20+
@Generated("com.querydsl.sql.codegen.MetaDataSerializer")
21+
public class QPizzaToppings extends com.querydsl.sql.RelationalPathBase<PizzaToppings> {
22+
23+
private static final long serialVersionUID = -213062036;
24+
25+
public static final QPizzaToppings pizzaToppings = new QPizzaToppings("PIZZA_TOPPINGS");
26+
27+
public final NumberPath<Long> pizzaId = createNumber("pizzaId", Long.class);
28+
29+
public final NumberPath<Long> toppingsId = createNumber("toppingsId", Long.class);
30+
31+
public final com.querydsl.sql.PrimaryKey<PizzaToppings> constraintA = createPrimaryKey(pizzaId, toppingsId);
32+
33+
public final com.querydsl.sql.ForeignKey<Topping> fk7tcti2cxau3csvbuwxn0scb93 = createForeignKey(toppingsId, "ID");
34+
35+
public final com.querydsl.sql.ForeignKey<Pizza> fk78l5qtferc9qhfkkgyv99lmst = createForeignKey(pizzaId, "ID");
36+
37+
public QPizzaToppings(String variable) {
38+
super(PizzaToppings.class, forVariable(variable), "PUBLIC", "PIZZA_TOPPINGS");
39+
addMetadata();
40+
}
41+
42+
public QPizzaToppings(String variable, String schema, String table) {
43+
super(PizzaToppings.class, forVariable(variable), schema, table);
44+
addMetadata();
45+
}
46+
47+
public QPizzaToppings(Path<? extends PizzaToppings> path) {
48+
super(path.getType(), path.getMetadata(), "PUBLIC", "PIZZA_TOPPINGS");
49+
addMetadata();
50+
}
51+
52+
public QPizzaToppings(PathMetadata metadata) {
53+
super(PizzaToppings.class, metadata, "PUBLIC", "PIZZA_TOPPINGS");
54+
addMetadata();
55+
}
56+
57+
public void addMetadata() {
58+
addMetadata(pizzaId, ColumnMetadata.named("PIZZA_ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull());
59+
addMetadata(toppingsId, ColumnMetadata.named("TOPPINGS_ID").withIndex(2).ofType(Types.BIGINT).withSize(19).notNull());
60+
}
61+
62+
}
63+

0 commit comments

Comments
 (0)