R2dbc Querydsl use Projections but log not print relation table
xeounxzxu opened this issue · 14 comments
hi , i use to r2dbc querydsl
when i use to single table dynamic projections , this is success work
but when i use to relationship table use to left join , this is fail work
this querydsl code
this logs code
this log is relationship table left join but this log not print left join
am I using it wrong?
thanks 😀
Hm, it should work based on all info provided.
Is there any exception, stacktrace?
Can you provide entities and sql for related tables? What's inside tables at the time of execution?
I am currently using MySql.
Also, I am using the following SQL.
We will also provide Kotlin Class.
No special exceptions are raised.
SQL
item
create table item
(
id bigint NOT NULL AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
type VARBINARY(255) null,
count bigint null,
limit_count bigint null,
CONSTRAINT item_pk PRIMARY KEY (id)
);
item_hsitory
create table item_history
(
id bigint NOT NULL AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
type VARBINARY(255) null,
count bigint null,
limit_count bigint null,
CONSTRAINT item_pk PRIMARY KEY (id),
constraint item_history_item_null_fk
foreign key (item_id) references item (id)
);
Kotlin
item
@Table(name = "item")
data class Item constructor(
@Id
val id: Long?,
val name: String?,
val type: ItemType?,
var count: Int = 0,
@Column("limit_count")
var limitCount: Int = 0
)
item_hsitory
@Table
data class ItemHistory constructor(
@Id
val id: Long? = null,
val name: String? = null,
val type: ItemType? = null,
val count: Int = 0,
var limitCount: Int = 0,
val itemId: Long
)
Can you please provide a project that reproduces this issue?
This is just a question.
I ran the test case but it doesn't work.
There seems to be a dependency on the test repository, can you please check?
If you're running this project tests - mssql instance should start in docker after some time and then the app should connect to it automatically. (logs you pasted above are normal).
I'm having issues running your example
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'initializer' defined in com.example.webflux.config.QuerydslTestConfiguration: Invocation of init method failed; nested exception is org.springframework.r2dbc.connection.init.ScriptStatementFailedException: Failed to execute SQL script statement #2 of class path resource [sql/item/schema.sql]: create table item_history ( id bigint NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, type VARBINARY(255) null, count bigint null, limit_count bigint null, created_at bigint null, CONSTRAINT item_pk PRIMARY KEY (id), constraint item_history_item_null_fk foreign key (item_id) references item (id) ); nested exception is io.r2dbc.spi.R2dbcBadGrammarException: [90045] [90045] Constraint "ITEM_PK" already exists; SQL statement:
create table item_history ( id bigint NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, type VARBINARY(255) null, count bigint null, limit_count bigint null, created_at bigint null, CONSTRAINT item_pk PRIMARY KEY (id), constraint item_history_item_null_fk foreign key (item_id) references item (id) ) [90045-214]
Ok, it builds and all test pass now.
Is there a test that reproduces the issue?
This is the findAll item and history
method in ItemQuerydslRepositoryTest.
Hm, the test still passes and I don't understand from the code what is expected to happen.
This is not an error.
However, I confirmed that the join clause is not used.
I'll check more and let you know.
I'm closing this down as stale. Feel free to reopen if you can provide more info or a reproduction.