简体   繁体   中英

Parameter not bound in Hibernate Query

I tried to make a query withSpring data for updating an entry by id and I tried a lot options but still I can't get rid of this:

Named parameter not bound : table.eventDate
@Modifying
@Query(value = "update Table_name u set u.id = :table.id, u.event_date = :table.eventDate, u.client_id = :table.clientId, u.status = :table.status, u.status_date = :table.statusDate, u.creation_date = :table.creationDate, u.last_update_date = :table.lastUpdateDate where u.id = :table.id",
    nativeQuery = true)
void updateEntity(@Param("table") Table table);


How should I write the query in order to get rid of this?

I tried a lot of posibilities online to write the query but nothing worked.

Correct native query statement:

@Modifying
@Query(value = "update Table_name u set u.id = :table.id, u.event_date = :table.event_date, u.client_id = :table.client_id, u.status = :table.status, u.status_date = :table.status_date, u.creation_date = :table.creation_date, u.last_update_date = :table.last_update_date where u.id = :table.id",
    nativeQuery = true)
void updateEntity(@Param("table") Table table);

Since you're using a native query instead of a JPQL-Query, you have to write:table.event_date instead of:table.eventDate. Same counts for example:table.clientId, it has to be:table.client_id. Hope it'll work!

Native Queries: Always snake_case instead of camelCase, unless your column names are in camelCase, but I doubt that. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM