-->
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.  [ 1 post ] 
Author Message
 Post subject: Table on different schema and hbm2ddl generated create-scrip
PostPosted: Wed Jul 16, 2014 4:01 am 
Newbie

Joined: Wed Jan 19, 2011 4:39 am
Posts: 2
My application uses two schema and two persistence units.

I need that one Business Object mapped on the first schema/PU can read (and only read) data from a table mapped in the second schema/PU.

So I created a class mapped to the "foreign" table, with only the fields that I need with insertable and updatable set to false (so it should be read-only)

Code:
@Entity
@Table( name = "NETHZ_USER", schema = "IDMANLIGHT" )
@Inheritance( strategy = InheritanceType.JOINED )
public class CMNUser extends PersistentObject
{
    private static final long   serialVersionUID    = CmnSerialVersionUID.getSerialVersionUID();

    @Column( insertable = false, updatable = false )
    private String              firstName;

    @Column( insertable = false, updatable = false )
    private String              lastName;

    @Column( insertable = false, updatable = false )
    private String              nethzPrimaryUsername;

    // Empty constructor need by Hibernate/Envers
    public CMNUser()
    {
        super();
    }

    + getters and setters


and put it in the persistence.xml under the first PU too.

The problem is that to create the DB I use the Hibernate Tools (hbm2ddl) and when it generates the script to create the tables for the first PU, it generates the create table idmanlight.nethz_user too. When then it tries to execute the script there is the error: "No rights for schema idmanlight" (which is legal).

The point is that hbm2ddl shouldn't generate the creation of the table (which already happens by the second PU).

Is there a way to avoid this?

I hope I explained the problem well enough to be understood...


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

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.