Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed projections do not restrict column selection #789

Open
xeounxzxu opened this issue Oct 6, 2022 · 0 comments
Open

Closed projections do not restrict column selection #789

xeounxzxu opened this issue Oct 6, 2022 · 0 comments
Labels
type: bug A general bug

Comments

@xeounxzxu
Copy link

xeounxzxu commented Oct 6, 2022

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

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 6, 2022
@mp911de mp911de changed the title checked dynamic projections Closed projections do not restrict column selection Oct 7, 2022
@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants