Hi Gail, based on my understanding of Section 2.2 it seems that it should not be portable, but I think that it would be nice for Hibernate to support the feature.
On Thu, 9 Jul 2020 at 17:40, Gail Badner <gbad...@redhat.com> wrote: > Hi Christian, > > It actually does work already. > > I was just trying to get answers to the questions at the end of my email. > > > Would overriding a transient attribute be portable? If not, is that > something Hibernate would/should support? > > If the answer is "yes" to either of those, I'll add a test case to the test > suite. > > Thanks, > Gail > > On Thu, Jul 9, 2020 at 12:47 AM Christian Beikov < > christian.bei...@gmail.com> > wrote: > > > I agree, this should work. Do you have a JIRA ticket describing what the > > problem is? > > > > Am 09.07.2020 um 02:42 schrieb Gail Badner: > > > I *think* the following is valid, but I need confirmation. This mapping > > > does seem to work for Hibernate. > > > > > > A transient attribute, Employee#title, gets overridden as a persistent > > > attribute, Editor#title, stored in a column named "e_title". > > > > > > Writer#title is also transient, but Writer#group uses the same > "e_title" > > > column as a foreign key. That foreign key value is used to populate > > > Writer#title. > > > > > > @Entity > > > @Table(name="Employee") > > > @Inheritance(strategy = InheritanceType.SINGLE_TABLE) > > > @DiscriminatorColumn(name="department") > > > public abstract class Employee { > > > private String name; > > > private String title; > > > > > > @Id > > > public String getName() { > > > return name; > > > } > > > > > > @Transient > > > public String getTitle() { > > > return title; > > > } > > > > > > protected void setName(String name) { > > > this.name = name; > > > } > > > > > > protected void setTitle(String title) { > > > this.title = title; > > > } > > > } > > > > > > @Entity > > > public class Editor extends Employee { > > > @Column(name = "e_title") > > > public String getTitle() { > > > return super.getTitle(); > > > } > > > > > > public void setTitle(String title) { > > > super.setTitle( title ); > > > } > > > } > > > > > > @Entity > > > public class Writer extends Employee { > > > private Group group; > > > > > > @ManyToOne(optional = false) > > > @JoinColumn(name = "e_title") > > > public Group getGroup() { > > > return group; > > > } > > > > > > public void setGroup(Group group) { > > > this.group = group; > > > setTitle( group.getName() ); > > > } > > > } > > > > > > In 4.2, the above mapping worked with Employee#title being persistent, > > but > > > does not work in 5.3. > > > > > > Section 2.2 Persistent Fields and Properties of the spec says: > > > > > > "Entity subclasses may override the property accessor methods. However, > > > portable applications must not override the object/relational mapping > > > metadata that applies to the persistent fields or properties of entity > > > superclasses." > > > > > > Would overriding a transient attribute be portable? If not, is that > > > something Hibernate would/should support? > > > > > > Thanks, > > > Gail > > > _______________________________________________ > > > hibernate-dev mailing list > > > hibernate-dev@lists.jboss.org > > > https://lists.jboss.org/mailman/listinfo/hibernate-dev > > _______________________________________________ > > hibernate-dev mailing list > > hibernate-dev@lists.jboss.org > > https://lists.jboss.org/mailman/listinfo/hibernate-dev > > > > > _______________________________________________ > hibernate-dev mailing list > hibernate-dev@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/hibernate-dev > > _______________________________________________ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev