You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by sgjava <sg...@gmail.com> on 2015/12/21 22:25:53 UTC

Bean validation with JCache

OK, my non-cached services have the payloads validated now, but one annotated
with @CacheResult is throwing a NPE if accountId is null. I'm using a
parameter annotation instead of a instance variable annotation.

DTO:

    @ConstructorProperties({"customerGuid", "masIp", "maxAgeMs", "transId",
        "accountId"})
    public CustStbDto(final String customerGuid, final String masIp,
            final Long maxAgeMs, final Long transId,
            @NotNull final String accountId) {

Service:

    @Path("/someurl")
    @POST
    @ValidateOnExecution
    @Valid
    public Response getCustomerSTBData(@Valid final CustStbDto custStbDto) {
        CustStbDto retCustStbDto = masBean.getCustomerSTBData(custStbDto.
                getGetCustomerSTBData().getAccountId(), custStbDto);

Bean:

    @CacheResult(cacheName = "customerStbData")
    public CustStbDto getCustomerSTBData(@CacheKey final String accountId,
            final CustStbDto custStbDto) {
        log.debug("Not in cache");

GeneratedCacheKey:

    public StringGeneratedCacheKey(final String val) {
        this.value = val;
        this.cachedHash = val.hashCode();
    }

It's NPE on this.cachedHash = val.hashCode();



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Bean-validation-with-JCache-tp4677284.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Bean validation with JCache

Posted by Steve Goldsmith <sg...@gmail.com>.
I cannot post this code, but I can build a stand alone example tonight,
thanks!

On Mon, Dec 21, 2015 at 4:51 PM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> guess you will need to put it on github cause with this mail we can;t say
> if your constructor is valid and what is returning getGetCustomerSTBData()
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
>
> 2015-12-21 22:25 GMT+01:00 sgjava <sg...@gmail.com>:
>
> > OK, my non-cached services have the payloads validated now, but one
> > annotated
> > with @CacheResult is throwing a NPE if accountId is null. I'm using a
> > parameter annotation instead of a instance variable annotation.
> >
> > DTO:
> >
> >     @ConstructorProperties({"customerGuid", "masIp", "maxAgeMs",
> "transId",
> >         "accountId"})
> >     public CustStbDto(final String customerGuid, final String masIp,
> >             final Long maxAgeMs, final Long transId,
> >             @NotNull final String accountId) {
> >
> > Service:
> >
> >     @Path("/someurl")
> >     @POST
> >     @ValidateOnExecution
> >     @Valid
> >     public Response getCustomerSTBData(@Valid final CustStbDto
> custStbDto)
> > {
> >         CustStbDto retCustStbDto = masBean.getCustomerSTBData(custStbDto.
> >                 getGetCustomerSTBData().getAccountId(), custStbDto);
> >
> > Bean:
> >
> >     @CacheResult(cacheName = "customerStbData")
> >     public CustStbDto getCustomerSTBData(@CacheKey final String
> accountId,
> >             final CustStbDto custStbDto) {
> >         log.debug("Not in cache");
> >
> > GeneratedCacheKey:
> >
> >     public StringGeneratedCacheKey(final String val) {
> >         this.value = val;
> >         this.cachedHash = val.hashCode();
> >     }
> >
> > It's NPE on this.cachedHash = val.hashCode();
> >
> >
> >
> > --
> > View this message in context:
> >
> http://tomee-openejb.979440.n4.nabble.com/Bean-validation-with-JCache-tp4677284.html
> > Sent from the TomEE Users mailing list archive at Nabble.com.
> >
>



-- 
Steven P. Goldsmith

Re: Bean validation with JCache

Posted by sgjava <sg...@gmail.com>.
I basically added bean validation to my JCache example at
https://github.com/sgjava/jcache-tomee and it appears to be working. I'll
have to check my code in the morning since I might be missing something.



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Bean-validation-with-JCache-tp4677284p4677289.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Bean validation with JCache

Posted by Romain Manni-Bucau <rm...@gmail.com>.
guess you will need to put it on github cause with this mail we can;t say
if your constructor is valid and what is returning getGetCustomerSTBData()


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-12-21 22:25 GMT+01:00 sgjava <sg...@gmail.com>:

> OK, my non-cached services have the payloads validated now, but one
> annotated
> with @CacheResult is throwing a NPE if accountId is null. I'm using a
> parameter annotation instead of a instance variable annotation.
>
> DTO:
>
>     @ConstructorProperties({"customerGuid", "masIp", "maxAgeMs", "transId",
>         "accountId"})
>     public CustStbDto(final String customerGuid, final String masIp,
>             final Long maxAgeMs, final Long transId,
>             @NotNull final String accountId) {
>
> Service:
>
>     @Path("/someurl")
>     @POST
>     @ValidateOnExecution
>     @Valid
>     public Response getCustomerSTBData(@Valid final CustStbDto custStbDto)
> {
>         CustStbDto retCustStbDto = masBean.getCustomerSTBData(custStbDto.
>                 getGetCustomerSTBData().getAccountId(), custStbDto);
>
> Bean:
>
>     @CacheResult(cacheName = "customerStbData")
>     public CustStbDto getCustomerSTBData(@CacheKey final String accountId,
>             final CustStbDto custStbDto) {
>         log.debug("Not in cache");
>
> GeneratedCacheKey:
>
>     public StringGeneratedCacheKey(final String val) {
>         this.value = val;
>         this.cachedHash = val.hashCode();
>     }
>
> It's NPE on this.cachedHash = val.hashCode();
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Bean-validation-with-JCache-tp4677284.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>