java - Native insert JPA Spring -
i have many-to-many relationship between 2 entities:
entity a
id
name
entity b
id
name
join table a_b
a_id
b_id
i'm trying insert based off of secondary unique attributes (names). want avoid fetching each entity name , saving (2 queries & 1 insert vs 1 insert). effectively, i'm looking this:
@query(nativequery = true, value = "insert a_b(a_id, b_id) values ((select id name = ?), (select id b name = ?))") void addtojointable(string namea, string nameb);
i saw this post, i'm getting exceptions because insert doesn't return result set. post mentions setting nativequery true resolve issue, i've had no such luck... there & better way this?
disclaimer: new jpa, might stupid question...
Comments
Post a Comment