diff --git a/querydsl-examples/pom.xml b/querydsl-examples/pom.xml index 2c95e2b97..d81161fb9 100644 --- a/querydsl-examples/pom.xml +++ b/querydsl-examples/pom.xml @@ -24,6 +24,8 @@ querydsl-example-sql-spring querydsl-example-sql-guice querydsl-example-jpa-guice + querydsl-example-kotlin-jpa + querydsl-example-kotlin-mongodb diff --git a/querydsl-examples/querydsl-example-kotlin-jpa/pom.xml b/querydsl-examples/querydsl-example-kotlin-jpa/pom.xml new file mode 100644 index 000000000..7659bdfc3 --- /dev/null +++ b/querydsl-examples/querydsl-example-kotlin-jpa/pom.xml @@ -0,0 +1,130 @@ + + + + querydsl-examples + com.querydsl + 5.0.0-SNAPSHOT + + 4.0.0 + querydsl-example-kotlin + + + 1.4.10 + + + + + jakarta.persistence + jakarta.persistence-api + 2.2.3 + + + com.querydsl + querydsl-jpa + ${project.version} + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-test-junit + ${kotlin.version} + test + + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + jpa + + + + com.querydsl + querydsl-apt + ${project.version} + jpa + + + 1.8 + + + + org.jetbrains.kotlin + kotlin-maven-allopen + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-maven-noarg + ${kotlin.version} + + + + + kapt + + kapt + + + + src/main/kotlin + src/main/java + + + + + compile + process-sources + + compile + + + + src/main/kotlin + src/main/java + + + + + test-kapt + + test-kapt + + + + src/test/kotlin + src/test/java + + + + + test-compile + + test-compile + + + + src/test/kotlin + src/test/java + target/generated-sources/kapt/test + + + + + + + + \ No newline at end of file diff --git a/querydsl-examples/querydsl-example-kotlin-jpa/src/main/kotlin/com/querydsl/examples/kotlin/entity/ExampleEntity.kt b/querydsl-examples/querydsl-example-kotlin-jpa/src/main/kotlin/com/querydsl/examples/kotlin/entity/ExampleEntity.kt new file mode 100644 index 000000000..bbda29705 --- /dev/null +++ b/querydsl-examples/querydsl-example-kotlin-jpa/src/main/kotlin/com/querydsl/examples/kotlin/entity/ExampleEntity.kt @@ -0,0 +1,36 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team). + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 com.querydsl.examples.kotlin.entity + +import javax.persistence.* + +@Entity +data class ExampleEntity( + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + val id: Int, + + @Column + val name: String, + + @OneToMany(mappedBy = "parent") + val children: List? = null, + + @ManyToOne + val parent: ExampleEntity? = null +) { +} \ No newline at end of file diff --git a/querydsl-examples/querydsl-example-kotlin-jpa/src/test/kotlin/com/querydsl/examples/kotlin/ExampleEntityTest.kt b/querydsl-examples/querydsl-example-kotlin-jpa/src/test/kotlin/com/querydsl/examples/kotlin/ExampleEntityTest.kt new file mode 100644 index 000000000..dd8b5425a --- /dev/null +++ b/querydsl-examples/querydsl-example-kotlin-jpa/src/test/kotlin/com/querydsl/examples/kotlin/ExampleEntityTest.kt @@ -0,0 +1,37 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team). + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 com.querydsl.examples.kotlin + +import com.querydsl.examples.kotlin.entity.ExampleEntity +import com.querydsl.examples.kotlin.entity.QExampleEntity +import com.querydsl.examples.kotlin.entity.QExampleEntity.exampleEntity +import com.querydsl.jpa.impl.JPAQuery +import org.junit.Test + +class ExampleEntityTest { + + @Test + fun basicMetamodelExpression() { + val child : QExampleEntity = QExampleEntity("child") + + JPAQuery() + .from(exampleEntity) + .innerJoin(exampleEntity.children, child) + .select(exampleEntity.name, child.name) + } + +} \ No newline at end of file diff --git a/querydsl-examples/querydsl-example-kotlin-mongodb/pom.xml b/querydsl-examples/querydsl-example-kotlin-mongodb/pom.xml new file mode 100644 index 000000000..f92b5b758 --- /dev/null +++ b/querydsl-examples/querydsl-example-kotlin-mongodb/pom.xml @@ -0,0 +1,156 @@ + + + + querydsl-examples + com.querydsl + 5.0.0-SNAPSHOT + + 4.0.0 + querydsl-example-kotlin-mongodb + + + 1.4.10 + + + + + + + org.springframework.boot + spring-boot-starter-parent + 2.3.4.RELEASE + pom + import + + + + + + + org.springframework.boot + spring-boot-starter-data-mongodb + + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.vintage + junit-vintage-engine + + + + + com.querydsl + querydsl-mongodb + ${project.version} + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-test-junit + ${kotlin.version} + test + + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + + com.querydsl + querydsl-apt + ${project.version} + + + + org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor + + 1.8 + + + + org.jetbrains.kotlin + kotlin-maven-allopen + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-maven-noarg + ${kotlin.version} + + + + + kapt + + kapt + + + + src/main/kotlin + src/main/java + + + + + compile + process-sources + + compile + + + + src/main/kotlin + src/main/java + + + + + test-kapt + + test-kapt + + + + src/test/kotlin + src/test/java + + + + + test-compile + + test-compile + + + + src/test/kotlin + src/test/java + target/generated-sources/kapt/test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file diff --git a/querydsl-examples/querydsl-example-kotlin-mongodb/src/main/kotlin/com/querydsl/examples/kotlin/entity/ExampleEntity.kt b/querydsl-examples/querydsl-example-kotlin-mongodb/src/main/kotlin/com/querydsl/examples/kotlin/entity/ExampleEntity.kt new file mode 100644 index 000000000..7b79f65f2 --- /dev/null +++ b/querydsl-examples/querydsl-example-kotlin-mongodb/src/main/kotlin/com/querydsl/examples/kotlin/entity/ExampleEntity.kt @@ -0,0 +1,33 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team). + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 com.querydsl.examples.kotlin.entity + +import com.querydsl.core.annotations.QueryEntity +import org.springframework.data.annotation.Id +import org.springframework.data.mongodb.core.mapping.Document + +@Document +@QueryEntity +data class ExampleEntity( + @Id + val id: Int, + + val name: String, + + val age : Int +) { +} \ No newline at end of file diff --git a/querydsl-examples/querydsl-example-kotlin-mongodb/src/main/kotlin/com/querydsl/examples/kotlin/repository/ExampleEntityRespository.kt b/querydsl-examples/querydsl-example-kotlin-mongodb/src/main/kotlin/com/querydsl/examples/kotlin/repository/ExampleEntityRespository.kt new file mode 100644 index 000000000..fc3bee88a --- /dev/null +++ b/querydsl-examples/querydsl-example-kotlin-mongodb/src/main/kotlin/com/querydsl/examples/kotlin/repository/ExampleEntityRespository.kt @@ -0,0 +1,24 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team). + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 com.querydsl.examples.kotlin.repository + +import com.querydsl.examples.kotlin.entity.ExampleEntity +import org.springframework.data.mongodb.repository.MongoRepository +import org.springframework.data.querydsl.QuerydslPredicateExecutor + +interface ExampleEntityRespository : MongoRepository, QuerydslPredicateExecutor { +} \ No newline at end of file diff --git a/querydsl-examples/querydsl-example-kotlin-mongodb/src/main/kotlin/com/querydsl/examples/kotlin/repository/ExampleUse.kt b/querydsl-examples/querydsl-example-kotlin-mongodb/src/main/kotlin/com/querydsl/examples/kotlin/repository/ExampleUse.kt new file mode 100644 index 000000000..c5cd68352 --- /dev/null +++ b/querydsl-examples/querydsl-example-kotlin-mongodb/src/main/kotlin/com/querydsl/examples/kotlin/repository/ExampleUse.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team). + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 com.querydsl.examples.kotlin.repository + +import com.querydsl.examples.kotlin.entity.QExampleEntity + +class ExampleUse { + + fun test() { + val qExampleEntity = QExampleEntity("test"); + } + +} \ No newline at end of file diff --git a/querydsl-examples/querydsl-example-kotlin-mongodb/src/test/kotlin/com/querydsl/examples/kotlin/ExampleEntityTest.kt b/querydsl-examples/querydsl-example-kotlin-mongodb/src/test/kotlin/com/querydsl/examples/kotlin/ExampleEntityTest.kt new file mode 100644 index 000000000..2ea4c8d7a --- /dev/null +++ b/querydsl-examples/querydsl-example-kotlin-mongodb/src/test/kotlin/com/querydsl/examples/kotlin/ExampleEntityTest.kt @@ -0,0 +1,30 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team). + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 com.querydsl.examples.kotlin + +import com.querydsl.examples.kotlin.entity.QExampleEntity +import org.junit.Test + +class ExampleEntityTest { + + @Test + fun basicMetamodelExpression() { + val example : QExampleEntity = QExampleEntity("example") + val predicate = example.name.eq("Eric") + } + +} \ No newline at end of file