-->
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: SQL Error: 0, SQLState: 42P01 with Map relation
PostPosted: Fri Oct 07, 2011 5:28 pm 
Newbie

Joined: Fri Oct 07, 2011 5:13 pm
Posts: 2
I have an exception when loading an object with @OneToMany map relation, which seems like a bug. Here is the object class:

Code:
@Entity
@Table(name = "customer")
public class Customer implements java.io.Serializable {

   private Integer custId;
        private String firstName;
        private String middleName;
        private String familyName;
   private Contact contact;
   private BigDecimal discount;
        @OneToMany(cascade= CascadeType.ALL, fetch= FetchType.EAGER)
        @MapKey(name="addresstype")
   private Map<Addresstype, Address> customerAddresses = new EnumMap<Addresstype, Address>(Addresstype.class);
}


The mapping class:
Code:
@Entity
@Table(name = "address", schema="bookstore")
public class Address implements java.io.Serializable {

   private Integer addressId;
        @Enumerated(EnumType.STRING)
   private Addresstype addresstype;


The persistence.xml also contains the default_schema property:
Code:
<property name="hibernate.default_schema" value="bookstore"/>


For loading a Customer object hibernate generates the following sql:
Code:
select
        customer0_.custID as custID251_4_,
        customer0_.contactID as contactID251_4_,
        customer0_.discount as discount251_4_,
        customer0_.familyName as familyName251_4_,
        customer0_.firstName as firstName251_4_,
        customer0_.middleName as middleName251_4_,
        addresses1_.customer_custID as customer1_251_6_,
        address2_.addressID as addresses2_6_,
        (select
            a13.addresstype
        from
            address a13
        where
            a13.addressID=addresses1_.addresses_addressID) as formula2_6_,
        address2_.addressID as addressID283_0_,
        address2_.addresstype as addresst2_283_0_,
        address2_.city as city283_0_,
        address2_.country_ID as country8_283_0_,
        address2_.department as department283_0_,
        address2_.institution as institut5_283_0_,
        address2_.state as state283_0_,
        address2_.street as street283_0_,
        country3_.ID as ID258_1_,
        country3_.abbr as abbr258_1_,
        country3_.Name as Name258_1_,
        country3_.regionID as regionID258_1_,
        region4_.ID as ID272_2_,
        region4_.Name as Name272_2_,
        contact5_.ID as ID250_3_,
        contact5_.email as email250_3_,
        contact5_.fax as fax250_3_,
        contact5_.tel as tel250_3_,
        contact5_.web as web250_3_
    from
        bookstore.customer customer0_
    left outer join
        bookstore.customer_address addresses1_
            on customer0_.custID=addresses1_.customer_custID
    left outer join
        bookstore.address address2_
            on addresses1_.addresses_addressID=address2_.addressID
    left outer join
        bookstore.country country3_
            on address2_.country_ID=country3_.ID
    left outer join
        bookstore.region region4_
            on country3_.regionID=region4_.ID
    left outer join
        bookstore.contact contact5_
            on customer0_.contactID=contact5_.ID
    where
        customer0_.custID=?

All tables except the the one in subquery have a schema prefixed and the unprefixed schema causes SQL Error: 0, SQLState: 42P01: "SEVERE: ERROR: relation "address" does not exist". Does somebody know how to solve this problem?


Top
 Profile  
 
 Post subject: Re: SQL Error: 0, SQLState: 42P01 with Map relation
PostPosted: Sat Oct 08, 2011 12:46 am 
Newbie

Joined: Fri Oct 07, 2011 5:13 pm
Posts: 2
I forgot to tell that the database is Postgre 9 and all other relationships are loaded fine. The problem only with this one, which is unidirectional and represented as a map.


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.