These are chat archives for hibernate/hibernate-orm

22nd
Sep 2017
cthlo
@cthlo
Sep 22 2017 17:35
Hi
Can an entity be embeddable ?
ryan2049
@ryan2049
Sep 22 2017 17:36
An Embeddable can be embedded
Lol
cthlo
@cthlo
Sep 22 2017 17:40
lol
I mean, can an embedable be persisted ?
So basically, I have a table with field a,b,c, and a view on this table with an extra computed field d
I would like to 2 classes, one for the table, one for the view, but be able to reuse the fields from one class
Not sure if i'm making any sense
Can I extends the class without enabling hibernate's inheritance ?
ryan2049
@ryan2049
Sep 22 2017 17:45
You can make the fields read only and hibernate will ignore them
cthlo
@cthlo
Sep 22 2017 18:12
I think I'm going with having a MappedSuperClass, and have those two entities extend it to get the common fields
ryan2049
@ryan2049
Sep 22 2017 19:10
that sounds like a sensible approach
your original statement made it sound like you wanted to use the @Embeddable and @Entity annotation on the same type
I don't believe hibernate will accept that
@Embeddable is just used to encapsulate fields on a table into their own inner class on the @Entity
cthlo
@cthlo
Sep 22 2017 23:43
True. Thanks @ryan2049 !
Happy Friday!