-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Mapping a view as entity makes schemaupdate fail
PostPosted: Thu Aug 20, 2009 3:15 am 
Newbie

Joined: Thu Aug 20, 2009 3:00 am
Posts: 11
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


Top
 Profile  
 
 Post subject: Re: Mapping a view as entity makes schemaupdate fail
PostPosted: Thu Aug 20, 2009 10:29 am 
Newbie

Joined: Thu Aug 20, 2009 3:00 am
Posts: 11
Worked around it by using a named native query. Together with @Loader this solved my problem. Could be simpler but at least I got rid of the error messages.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.