How To Insert Using A Select In Hibernate
I need to implement the following request in hibernate: insert into my_table(....,max_column) values(...,(select max(id) from special_table where ....)) How to do that in hibernat
Solution 1:
You can use the INSERT INTO ... SELECT ... feature:
int updateCount = session.createQuery("""
insert into MyEntity(
...,
max_column
)
select
...,
max(id)
from SpecialEntity
""")
.executeUpdate();
Post a Comment for "How To Insert Using A Select In Hibernate"