syncope-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francesco Chicchiriccò <ilgro...@apache.org>
Subject Re: JPAConfDao ClassCastException
Date Tue, 13 Dec 2016 12:40:07 GMT
On 13/12/2016 13:31, Colm O hEigeartaigh wrote:
> The following case in JPAConfDao will result in a ClassCastException as
> JPACPlainAttrValue does not implement the interface PlainAttrUniqueValue.
>
> JPACPlainAttrValue attrValue;
> if (newAttr.getSchema().isUniqueConstraint()) {
>      attrValue = new JPACPlainAttrValue();
>      ((PlainAttrUniqueValue) attrValue).setSchema(newAttr.getSchema());
> }
>
> What should this be instead?


I guess you are referring to [1]; to me, the highlighted snippet should 
become

                 PlainAttrValue attrValue;
                 if (newAttr.getSchema().isUniqueConstraint()) {
                     attrValue = new JPACPlainAttrUniqueValue();
                     ((PlainAttrUniqueValue) 
attrValue).setSchema(newAttr.getSchema());
                 } else {
                     attrValue = new JPACPlainAttrValue();
                 }

WDYT?

[1] 
https://github.com/apache/syncope/blob/2_0_X/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAConfDAO.java#L71-L77

-- 
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

Member at The Apache Software Foundation
Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail
http://home.apache.org/~ilgrosso/


Mime
View raw message