You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@syncope.apache.org by Colm O hEigeartaigh <co...@apache.org> on 2016/12/13 12:31:35 UTC

JPAConfDao ClassCastException

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?

Colm.



-- 
Colm O hEigeartaigh

Talend Community Coder
http://coders.talend.com

Re: JPAConfDao ClassCastException

Posted by Colm O hEigeartaigh <co...@apache.org>.
Yes that makes sense to me, I'll fix that as part of my merge, thanks!

Colm.

On Tue, Dec 13, 2016 at 12:40 PM, Francesco Chicchiriccò <
ilgrosso@apache.org> wrote:

> 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.g
> etSchema());
>                 } else {
>                     attrValue = new JPACPlainAttrValue();
>                 }
>
> WDYT?
>
> [1] https://github.com/apache/syncope/blob/2_0_X/core/persistenc
> e-jpa/src/main/java/org/apache/syncope/core/persistenc
> e/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/
>
>


-- 
Colm O hEigeartaigh

Talend Community Coder
http://coders.talend.com

Re: JPAConfDao ClassCastException

Posted by Francesco Chicchiriccò <il...@apache.org>.
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/