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

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -