Skip to content

Closed projections do not restrict column selection #789

Open
@xeounxzxu

Description

@xeounxzxu

Hi,

I use to this lib and i use projections

But not working to dynamic projections ... ?

code

@Table(name = "item")
data class Item constructor(
    @Id
    val id: Long?,
    val name: String?,
    val type: ItemType?,
    val count: Int?,
    @Column("limit_count")
    val limitCount: Int?,
    @Column("created_at")
    val createdAt: Long?,
) {

    // created new item(product) constructor
    constructor(
        name: String,
        type: ItemType = ItemType.WAIT,
        count: Int = 0,
        limitCount: Int = 0,
        createdAt: Long? = System.currentTimeMillis(),
    ) : this(
        id = null,
        name = name,
        type = type,
        count = count,
        limitCount = limitCount,
        createdAt = createdAt
    )
}


@Repository
interface ItemRepository : CoroutineSortingRepository<Item, Long> {

    suspend fun findByName(name: String): Item?

    suspend fun <T> findByName(name: String, type: Class<T>): T?

    suspend fun findItemByName(name: String): OnlyItemName?
    
    suspend fun <T> findItemByName(name: String , type : Class<T>): T?
}

projections

interface OnlyItemName {
    fun getName(): String
}

I use to method suspend fun <T> findByName(name: String, type: Class<T>): T? ,

But this method is print this

Executing SQL statement [SELECT item.id, item.name, item.type, item.count, item.limit_count, item.created_at FROM item WHERE item.name = ?]

My guess is that the reason for using the projections is to change the selection in the query, but to show everything in the console above.

Did I possibly set the wrong settings?

thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions