You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "shuikan95 (via GitHub)" <gi...@apache.org> on 2023/04/02 05:20:32 UTC
[GitHub] [shardingsphere] shuikan95 commented on issue #24913: Not work with readwrite-splitting when using Spring Data JPA
shuikan95 commented on issue #24913:
URL: https://github.com/apache/shardingsphere/issues/24913#issuecomment-1493226926
@strongduanmu @insist777
Some other tests give me different results.
> Will to choose read datasource
```html
org.springframework.data.jpa.repository.Query;
@Query(value = "select a.money,a.user_id from account_tbl a", nativeQuery = true)
List<Map<String, Object>> findSome1();
@Query(value = "select new map(a.money as money,a.userId as userId) from Account a")
List<Map<String, Object>> findSome2();
JPA with QueryDSL
com.querydsl.jpa.impl.JPAQueryFactory
QAccount qAccount = QAccount.account;
List<Map<Expression<?>, ?>> fetch = jpaQueryFactory
.select(Projections.map(qAccount))
.from(qAccount)
.orderBy(qAccount.id.desc())
.fetch();
org.springframework.data.jpa.repository.JpaRepository#getById // Need to set spring.jpa.open-in-view=true
```
> Will to choose write datasource
```html
org.springframework.data.repository.CrudRepository#findById
org.springframework.data.jpa.repository.JpaRepository#findAll
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org