-
Notifications
You must be signed in to change notification settings - Fork 200
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
8 changed files
with
171 additions
and
19 deletions.
There are no files selected for viewing
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
33 changes: 33 additions & 0 deletions
33
data-jdbc/src/test/groovy/io/micronaut/data/jdbc/h2/one2one/select/MyEmbedded.java
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,33 @@ | ||
package io.micronaut.data.jdbc.h2.one2one.select; | ||
|
||
import io.micronaut.data.annotation.AutoPopulated; | ||
import io.micronaut.data.annotation.Id; | ||
import io.micronaut.data.annotation.MappedEntity; | ||
|
||
import java.util.UUID; | ||
|
||
@MappedEntity | ||
public class MyEmbedded { | ||
|
||
@Id | ||
@AutoPopulated | ||
private UUID id; | ||
|
||
private String someProp; | ||
|
||
public UUID getId() { | ||
return id; | ||
} | ||
|
||
public void setId(UUID id) { | ||
this.id = id; | ||
} | ||
|
||
public String getSomeProp() { | ||
return someProp; | ||
} | ||
|
||
public void setSomeProp(String someProp) { | ||
this.someProp = someProp; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
data-jdbc/src/test/groovy/io/micronaut/data/jdbc/h2/one2one/select/MyOrder.java
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,37 @@ | ||
package io.micronaut.data.jdbc.h2.one2one.select; | ||
|
||
import io.micronaut.core.annotation.Nullable; | ||
import io.micronaut.data.annotation.AutoPopulated; | ||
import io.micronaut.data.annotation.Id; | ||
import io.micronaut.data.annotation.MappedEntity; | ||
import io.micronaut.data.annotation.Relation; | ||
|
||
import java.util.UUID; | ||
|
||
@MappedEntity | ||
public class MyOrder { | ||
|
||
@Id | ||
@AutoPopulated | ||
private UUID orderId; | ||
|
||
@Nullable | ||
@Relation(value = Relation.Kind.ONE_TO_ONE) | ||
private MyEmbedded embedded; | ||
|
||
public UUID getOrderId() { | ||
return orderId; | ||
} | ||
|
||
public void setOrderId(UUID orderId) { | ||
this.orderId = orderId; | ||
} | ||
|
||
public MyEmbedded getEmbedded() { | ||
return embedded; | ||
} | ||
|
||
public void setEmbedded(MyEmbedded embedded) { | ||
this.embedded = embedded; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
data-jdbc/src/test/groovy/io/micronaut/data/jdbc/h2/one2one/select/MyOrderRepository.java
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,23 @@ | ||
package io.micronaut.data.jdbc.h2.one2one.select; | ||
|
||
import io.micronaut.core.annotation.NonNull; | ||
import io.micronaut.data.annotation.Join; | ||
import io.micronaut.data.annotation.repeatable.JoinSpecifications; | ||
import io.micronaut.data.jdbc.annotation.JdbcRepository; | ||
import io.micronaut.data.model.Page; | ||
import io.micronaut.data.model.Pageable; | ||
import io.micronaut.data.model.query.builder.sql.Dialect; | ||
import io.micronaut.data.repository.CrudRepository; | ||
import io.micronaut.data.repository.jpa.criteria.PredicateSpecification; | ||
|
||
import java.util.UUID; | ||
|
||
@JdbcRepository(dialect = Dialect.H2) | ||
public interface MyOrderRepository extends CrudRepository<MyOrder, UUID> { | ||
@NonNull | ||
@JoinSpecifications({ | ||
@Join(value = "embedded", type = Join.Type.LEFT_FETCH) | ||
}) | ||
Page<MyOrder> findAll(PredicateSpecification<MyOrder> spec, Pageable pageable); | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...bc/src/test/groovy/io/micronaut/data/jdbc/h2/one2one/select/OneToOneProjectionSpec.groovy
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,28 @@ | ||
package io.micronaut.data.jdbc.h2.one2one.select | ||
|
||
import io.micronaut.data.jdbc.h2.H2DBProperties | ||
import io.micronaut.data.model.Pageable | ||
import io.micronaut.data.model.Sort | ||
import io.micronaut.data.repository.jpa.criteria.PredicateSpecification | ||
import io.micronaut.test.extensions.spock.annotation.MicronautTest | ||
import jakarta.inject.Inject | ||
import spock.lang.Specification | ||
|
||
@H2DBProperties | ||
@MicronautTest(transactional = false) | ||
class OneToOneProjectionSpec extends Specification { | ||
|
||
@Inject | ||
MyOrderRepository orderRepository | ||
|
||
void findAll_withPageableSort_andSearch() { | ||
given: | ||
Sort.Order.Direction sortDirection = Sort.Order.Direction.ASC | ||
Pageable pageable = Pageable.UNPAGED.order(new Sort.Order("embedded.someProp", sortDirection, false)) | ||
PredicateSpecification<MyOrder> predicate = null | ||
when: | ||
orderRepository.findAll(predicate, pageable) | ||
then: | ||
noExceptionThrown() | ||
} | ||
} |
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
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
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