Hello,
For my question I'll first explain a test environment:
- Two tables: "users" and "groups"
- One MySQL view: union of "users" and "groups" named "mailaddresses"
I use this view to give people a list of all addresses an e-mail can be sent to. That includes users and they can be sent to groups.
I don't know of a way to do this nicely in JPA and so I just created an entity MailAddress and removed the underlying table and replaced it with a view. Problem is that hibernate keeps on trying to update the schema of this entity. But is is a view and so I get the errors:
Code:
2009-08-20 08:56:16,300 () ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate - Unsuccessful: alter table mailaddresses add index FKCD02F3CB9711C5A3 (lastChangedWorkstationId), add constraint FKCD02F3CB9711C5A3 foreign key (lastChangedWorkstationId) references workstations (id)
2009-08-20 08:56:16,320 () ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate - 'VetManager.mailaddresses' is not BASE TABLE
There are two possible ways of solving this (for which I don't know how to do that):
- Use something in JPA/Hibernate to make the union
- Disable SchemaUpdate for this specific Entity and leave it on for all others
Any advise?
Thanks,
Milo