java - How to map a database view without a primary key when using JPA -


  • i have views in sql database no obvious primary key (composite or otherwise)
  • i access them through jpa

i've read should able treat views in jpa treat tables (using @table annotation etc.). without primary key have make composite key out of every column (in fact, in hibernate's reverse-engineering tool seems default).

however if there undesirable side effects. e.g.

  • having write code pointing primary key's attributes rather views:

    myviewobject.getprimarykey().getfirstname()

  • not being able use "findby..." methods on spring repository (since attribute part of view's "identifier" , not 1 of it's attributes).

my question is: how map views in such can access attributes using jpa?

note: i'm quite happy told i'm using wrong approach. seems such common problem there's bound better solution.

you can add uuid column every row of views can use uuid column @id.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -