-->
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: @Type(type="pg-uuid") ignored for native query
PostPosted: Tue Mar 11, 2014 11:51 am 
Newbie

Joined: Tue Mar 11, 2014 11:26 am
Posts: 1
Entity definition:

Code:
@Entity
@javax.persistence.Table(name = "term", schema = "report")
public class ReportTermEntity {

    private UUID businessIdentifier;

    @Basic
    @javax.persistence.Column(name = "business_identifier", nullable = false, insertable = true, updatable = true)
    @Type(type="pg-uuid")
    public UUID getBusinessIdentifier() {
        return businessIdentifier;
    }

    public void setBusinessIdentifier(UUID businessIdentifier) {
        this.businessIdentifier = businessIdentifier;
    }
    ... etc.


Spring-Data Repository definition

Code:
public interface ReportTermRepository extends CrudRepository<ReportTermEntity, Long> {
    ReportTermEntity findByBusinessIdentifier(UUID businessIdentifier);
    ReportTermEntity findRandomTermWithNoGrowthWindow();
}


orm.xml

Code:
    <named-native-query name="ReportTermEntity.findRandomTermWithNoGrowthWindow">
        <query>
            select
                t.*
            from report.term t
            left join report.growth_measurement_window gw using(term_id)
            where gw.term_id is null
            order by 1
            limit 1
        </query>
    </named-native-query>


When I use findByBusinessIdentifier() there is no problem. When I use findRandomTermWithNoGrowthWindow() I get

Code:
org.hibernate.MappingException: No Dialect mapping for JDBC type: 1111


Where type 1111 is Postgres "Other" type, which of course Hibernate does not know how to handle. So it appears that @Type(type="pg-uuid") is being ignored for a native query but not for a generated query.

If I rewrite the native query as

Code:
            select
                t.term_id,
                cast(t.business_identifier as varchar),  --*** note cast to varchar
                ... remainder of t.* columns given explicitly ...
            from report.term t
            left join report.growth_measurement_window gw using(term_id)
            where gw.term_id is null
            order by 1
            limit 1



I get the following error:

Code:
org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.Object[] to type
    org.nwea.etl.data.orm.entity.report.ReportTermEntity for value
    '{569, 2f628b44-796a-4ad1-9eff-3750816b3726, 486, 200703, Summer 2006-2007, SU07, 2007, 2006-2007, 3, Summer, SU, 2007-06-16, 2007-08-14, 200703, false, false, idl, 2011-02-28 16:00:00.0, TCAdmin7, 2011-07-13 08:01:04.0, Load_Term, 2014-03-06 16:05:24.585, Load_Term, 2014-03-06 16:09:16.673, 8030}';
    nested exception is
        org.springframework.core.convert.ConverterNotFoundException:
        No converter found capable of converting from type java.lang.Integer to type org.nwea.etl.data.orm.entity.report.ReportTermEntity


Which looks like a bad error message since it's clearly not trying to convert Integer directly to ReportTermEntity.

Anybody have any suggestions on how to get past this?


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.