helidon-io / helidon

Java libraries for writing microservices
https://helidon.io
Apache License 2.0
3.52k stars 564 forks source link

Issue in Helidon - Ordinal binding and Named binding cannot be combined #4684

Closed kchaudhu closed 2 years ago

kchaudhu commented 2 years ago

//: "Issue in Helidon - Ordinal binding and Named binding cannot be combined" //: "Issue in Helidon - Ordinal binding and Named binding cannot be combined"

Environment Details


Problem Description

What is this exact issue every time its coming 'Ordinal binding and Named binding cannot be combined'

2022.07.29 16:55:31 WARN org.hibernate.engine.jdbc.spi.SqlExceptionHelper Thread[helidon-1,5,server]: SQL Error: 17090, SQLState: 99999 2022.07.29 16:55:31 ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper Thread[helidon-1,5,server]: operation not allowed: Ordinal binding and Named binding cannot be combined! 2022.07.29 16:55:31 WARNING io.helidon.microprofile.server.JaxRsCdiExtension Thread[helidon-1,5,server]: Internal server error java.lang.NullPointerException at com.enrollmentservice.controller.AddFamilyMemberController.getFamilyMemberListForDisplay(AddFamilyMemberController.java:400) at com.enrollmentservice.controller.AddFamilyMemberController$Proxy$_$$WeldSubclass.getFamilyMemberListForDisplay(Unknown Source) at com.enrollmentservice.controller.AddFamilyMemberController$Proxy$$$_WeldClientProxy.getFamilyMemberListForDisplay(Unknown Source) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167) at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:176) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79)

Error Codes

spericas commented 2 years ago

@kchaudhu This an SQL error, I don't see how it relates to Helidon. You seem to be mixing styles and using both names and indexes when accessing data in your SQL statements. Please share AddFamilyMemberController.java.

kchaudhu commented 2 years ago

Please find attached.

Thanks and regards Kallol Chaudhuri

Principal Technology Solutions Architect Oracle India Mobile :- +(91)9830270256 www.oracle.com

From: Santiago Pericasgeertsen @.> Sent: Monday, August 8, 2022 7:57 PM To: oracle/helidon @.> Cc: Kallol Chaudhuri @.>; Mention @.> Subject: [External] : Re: [oracle/helidon] Issue in Helidon - Ordinal binding and Named binding cannot be combined (Issue #4684)

@kchaudhuhttps://urldefense.com/v3/__https:/github.com/kchaudhu__;!!ACWV5N9M2RV99hQ!KopuRCettS18vQ9BJ_Fnpzgz4n5uVHGY_VGcDNZUD2xRboPKr-c88A_upOcE0RRPWQA0yfECXaqXCIF7UycJIUvhV7JWzw$ This an SQL error, I don't see how it relates to Helidon. You seem to be mixing styles and using both names and indexes when accessing data in your SQL statements. Please share AddFamilyMemberController.java.

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/oracle/helidon/issues/4684*issuecomment-1208202311__;Iw!!ACWV5N9M2RV99hQ!KopuRCettS18vQ9BJ_Fnpzgz4n5uVHGY_VGcDNZUD2xRboPKr-c88A_upOcE0RRPWQA0yfECXaqXCIF7UycJIUtntSJh0A$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AHS7UGDDHYKHBHKETWUQET3VYEKKBANCNFSM555CEMHQ__;!!ACWV5N9M2RV99hQ!KopuRCettS18vQ9BJ_Fnpzgz4n5uVHGY_VGcDNZUD2xRboPKr-c88A_upOcE0RRPWQA0yfECXaqXCIF7UycJIUvOuLcixw$. You are receiving this because you were mentioned.Message ID: @.**@.>>

package com.enrollmentservice.controller;

import java.nio.file.Files; import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map;

import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.transaction.Transactional; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response;

import org.glassfish.jersey.media.multipart.BodyPartEntity; import org.glassfish.jersey.media.multipart.FormDataBodyPart; import org.glassfish.jersey.media.multipart.FormDataParam;

import com.enrollmentservice.beans.AddMemberMemberBean; import com.enrollmentservice.model.AddMember_MemberDetails; import com.enrollmentservice.model.FamilyMember; import com.enrollmentservice.service.AddFamilyMemberService; import com.enrollmentservice.service.BasicDetailsService; import com.enrollmentservice.service.EmitraService; import com.enrollmentservice.service.OtpService; import com.enrollmentservice.util.AadhaarValidator; import com.enrollmentservice.util.BlurImageValidator; import com.enrollmentservice.util.FileStorage;

@Path("/enrollment") @RequestScoped public class AddFamilyMemberController {

@Inject
private FileStorage storage;

@Inject
AddFamilyMemberService service;

@Inject
private OtpService otpService;

@Inject
private BlurImageValidator validator;

@GET
@Transactional(Transactional.TxType.REQUIRED)
@Path("/generateOTPToValidateMobileOfMember")
public Response ***@***.***(value = "mobileNumber") String mobileNumber) {
    String otpResponse = null;
    Map<String, String> data = new HashMap<String, String>();
    try {
        if (mobileNumber == null)
            throw new Exception("Mobile number not found");

        otpResponse = otpService.generateOtp(mobileNumber);
        data.put("mobileNumber", mobileNumber);
        data.put("otpResponse", otpResponse);
        data.put("status", "success");
    } catch (Exception e) {
        data.put("status", "fail");
        data.put("msg", e.getMessage());
    }

    return Response.status(Response.Status.OK)
              .entity(data)
              .build();
}

@GET
@Path(value = "/verifyOTPToValidateFamilyMemberMobileNumber")
@Produces(MediaType.APPLICATION_JSON)
public Response ***@***.***("mobileNumber") String mobileNumber,
        @QueryParam("otp") String otp) {

    Map<String, String> response = new HashMap<>();
    boolean flag = false;       
    try {
        flag = otpService.isValidOtp(mobileNumber, otp);
        if(flag) {
            response.put("status", "success");
        }else {
            response.put("status", "fail");
            response.put("msg", "Invalid OTP");
        }
    } catch (Exception e) {
        response.put("status", "error");
        response.put("msg", e.getMessage());
        e.printStackTrace();
    }

    return Response.status(Response.Status.OK)
              .entity(response)

// .header("Access-Control-Allow-Origin", "*") .build(); }

@POST
@Path("/fetchDataFromSignUpForEnrollment")
@Produces(MediaType.APPLICATION_JSON)
public Response ***@***.***(value = "username") String username) {

    Map<String, Object> data = new HashMap<String, Object>();

    try {
        Map<String, Object> details = service.fetchDataFromSignUpForEnrollment(username);
        data.put("status", "Success");
        data.put("details", details);
    } catch (Exception e) {
        data.put("status", "Fail");
        data.put("msg", e.getMessage());
        if(e.getMessage().indexOf("No member found") != -1)
            data.put("status", "NO-DATA-FOUND");
        e.printStackTrace();
    }

    return Response.status(Response.Status.OK).entity(data).build();
}

@POST
@Path("/addFamilyMemberDetails")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public Response addFamilyMemberDetails(
        @FormDataParam(value = "user") String  user,
        @FormDataParam(value = "usertype") String  usertype,
        @FormDataParam(value = "hofId") String  hofId,
        @FormDataParam(value = "memberId") String  memberId,
        @FormDataParam(value = "adhaar_number") String  adhaar_number,
        @FormDataParam(value = "firstNameEng") String  firstNameEng, 
        @FormDataParam(value = "middleNameEng") String  middleNameEng, 
        @FormDataParam(value = "lastNameEng") String  lastNameEng, 
        @FormDataParam(value = "gender") String  gender,
        @FormDataParam(value = "dob") String  dob,
        @FormDataParam(value = "age") String  age,
        @FormDataParam(value = "isMemberOrphan") String  isMemberOrphan,
        @FormDataParam(value = "guardianNameEng") String  guardianNameEng,
        @FormDataParam(value = "fatherNameEng") String  fatherNameEng,
        @FormDataParam(value = "motherNameEng") String  motherNameEng,
        @FormDataParam(value = "casteCategory") String  casteCategory, 
        @FormDataParam(value = "caste") String  caste, 
        @FormDataParam(value = "isSpecialAbled") String  isSpecialAbled, 
        @FormDataParam(value = "specialAbledCertificateNo") String  specialAbledCertificateNo, 
        @FormDataParam(value = "specialAbledType") String  specialAbledType, 
        @FormDataParam(value = "percentageOfDisability") String  percentageOfDisability,
        @FormDataParam(value = "maritalStatus") String  maritalStatus, 
        @FormDataParam(value = "spouseNameEng") String  spouseNameEng, 
        @FormDataParam(value = "bloodGroup") String  bloodGroup, 
        @FormDataParam(value = "religion") String  religion, 
        @FormDataParam(value = "mobileNumber") String  mobileNumber, 
        @FormDataParam(value = "email") String  email, 
        @FormDataParam(value = "eductaionalLevel") String  eductaionalLevel,
        @FormDataParam(value = "occupation") String  occupation,
        @FormDataParam(value = "govtEmpId") String  govtEmpId,
        @FormDataParam(value = "ssppo") String  ssppo,
        @FormDataParam(value = "ddoNo") String  ddoNo, 
        @FormDataParam(value = "realIncome") String  realIncome,
        @FormDataParam(value = "artistType") String  artistType,
        @FormDataParam(value = "artistDescription") String  artistDescription,
        @FormDataParam(value = "ifsccode") String  ifsccode, 
        @FormDataParam(value = "bankId") String  bankId, 
        @FormDataParam(value = "bankName") String  bankName, 
        @FormDataParam(value = "bankBranchId") String  bankBranchId,
        @FormDataParam(value = "branchName") String  branchName,
        @FormDataParam(value = "bankAccountNumber") String  bankAccountNumber,
        @FormDataParam(value = "panNo") String  panNo, 
        @FormDataParam(value = "drivingLicenseNo") String  drivingLicenseNo,
        @FormDataParam(value = "passportNo") String  passportNo,
        @FormDataParam(value = "voterIdNo") String  voterIdNo,
        @FormDataParam(value = "labourCardNo") String  labourCardNo, 
        @FormDataParam(value = "labourCardExpiryDate") String  labourCardExpiryDate,
        @FormDataParam(value = "mngregaCardNo") String  mngregaCardNo,
        @FormDataParam(value = "farmerId") String  farmerId,
        @FormDataParam(value = "landowner") String  landowner,
        @FormDataParam(value = "photo") FormDataBodyPart  photo 
        ) {

    Map<String, Object> data = new HashMap<String, Object>();
    FamilyMember member = new FamilyMember();

    AadhaarValidator av = null;

    Response response = null;

    try {
        member.setUser(user);
        member.setUsertype(usertype);           
        try {
            member.setHofId(Long.valueOf(hofId));
        } catch (Exception e) {

// e.printStackTrace(); } try { member.setMemberId(Long.valueOf(memberId)); } catch (Exception e) { // e.printStackTrace(); } try { member.setAdhaar_number(Long.valueOf(adhaar_number)); } catch (Exception e) { // e.printStackTrace(); } member.setFirstNameEng(firstNameEng); member.setMiddleNameEng(middleNameEng); member.setLastNameEng(lastNameEng); try { member.setGender(Long.valueOf(gender)); } catch (Exception e) { // e.printStackTrace(); } member.setDob(dob); try { member.setAge(Integer.valueOf(age)); } catch (Exception e) { // e.printStackTrace(); } member.setIsMemberOrphan(isMemberOrphan); member.setGuardianNameEng(guardianNameEng); member.setFatherNameEng(fatherNameEng); member.setMotherNameEng(motherNameEng); try { member.setCasteCategory(Integer.valueOf(casteCategory)); } catch (Exception e) { // e.printStackTrace(); } try { member.setCaste(Integer.valueOf(caste)); } catch (Exception e) { // e.printStackTrace(); } member.setIsSpecialAbled(isSpecialAbled); member.setSpecialAbledCertificateNo(specialAbledCertificateNo); member.setSpecialAbledType(specialAbledType);

        try {
            member.setPercentageOfDisability(String.valueOf(Long.valueOf(percentageOfDisability)));
        } catch (Exception e) {

// e.printStackTrace(); } try { member.setMaritalStatus(Long.valueOf(maritalStatus)); } catch (Exception e) { // e.printStackTrace(); } member.setSpouseNameEng(spouseNameEng); try { member.setBloodGroup(Integer.valueOf(bloodGroup)); } catch (Exception e1) { // e1.printStackTrace(); } try { member.setReligion(Integer.valueOf(religion)); } catch (Exception e1) { // e1.printStackTrace(); } try { member.setMobileNumber(Long.valueOf(mobileNumber)); } catch (Exception e) { // e.printStackTrace(); } member.setEmail(email); try { member.setEductaionalLevel(Long.valueOf(eductaionalLevel)); } catch (Exception e) { // e.printStackTrace(); } try { member.setOccupation(Long.valueOf(occupation)); } catch (Exception e) { // e.printStackTrace(); } member.setGovtEmpId(govtEmpId); member.setSsppo(ssppo); member.setDdoNo(ddoNo); try { member.setRealIncome(Long.valueOf(realIncome)); } catch (Exception e) { // e.printStackTrace(); } try { member.setArtistType(Long.valueOf(artistType)); } catch (Exception e) { // e.printStackTrace(); } member.setArtistDescription(artistDescription); member.setIfsccode(ifsccode); try { member.setBankId(Long.valueOf(bankId)); } catch (Exception e) { // e.printStackTrace(); } member.setBankName(bankName); try { member.setBankBranchId(Long.valueOf(bankBranchId)); } catch (Exception e) { // e.printStackTrace(); } member.setBranchName(branchName); member.setBankAccountNumber(bankAccountNumber); member.setPanNo(panNo); member.setDrivingLicenseNo(drivingLicenseNo); member.setPassportNo(passportNo); member.setVoterIdNo(voterIdNo); member.setLabourCardNo(labourCardNo); // member.setLabourCardExpiryDate(labourCardExpiryDate); member.setMngregaCardNo(mngregaCardNo); member.setFarmerId(farmerId); try { member.setLandowner(Integer.valueOf(landowner)); } catch (Exception e) { e.printStackTrace(); } if(photo == null) throw new Exception("Photo mandetory"); member.setPhoto(photo);

        // Validate Photo For Blurring starts
        String timeStamp = String.valueOf(new Date().getTime());

        java.nio.file.Path location=storage.create(member.getPhoto().getContentDisposition().getFileName()+timeStamp);

        boolean flag=true;

        System.out.println("Starting ImageValidationController Controller..........");

        Files.copy(member.getPhoto().getEntityAs(BodyPartEntity.class).getInputStream(),
                location,
                StandardCopyOption.REPLACE_EXISTING);

        String path=location.toString();

// flag=validator.validateBlurImage(path);

        Files.delete(location);

        if(flag == false)
            throw new Exception("Blur Image");

        // Validation of photo ends

        System.out.println(member.toString());

        Map<String, Object> validationResult = service.isValidData(member);
        if(((String)validationResult.get("validation-status")).equalsIgnoreCase("fail")) {
            data.put("status", "INVALID-FIELD");
            data.put("fieldName", (String)validationResult.get("fieldName"));   
            data.put("msg", (String)validationResult.get("msg"));
        }else {
            if (member.getAdhaar_number()== null || av.isValidAadhaarNo(member.getAdhaar_number())) {
                member = service.addFamilyMemberDetails(member);
                System.out.println("adhar number:" + member.getAdhaar_number());
                data.put("status", "SUCCESS");

            } else {
                data.put("status", "VALIDATION_FAIL");
                data.put("msg", "Invalid aadhar number");
            }
        }

    }catch (Exception e) {
        e.printStackTrace();
        data.put("status", "FAIL");
        data.put("msg", e.getMessage());
        if(e.getMessage() == null)
            data.put("msg", "Null pointer exception");
        else if(e.getMessage().indexOf("ConstraintViolationException") != -1)
            data.put("status", "DUPLICATE-AADHAAR");
        else if(e.getMessage().indexOf("Photo mandetory") != -1)
            data.put("status", "INVALID-PHOTO");
        else if(e.getMessage().indexOf("File can not be converted to clob") != -1)
            data.put("status", "PHOTO-READ-FAIL");
        else if(e.getMessage().indexOf("Blur Image") != -1)
            data.put("status", "BLUR-PHOTO");
        else if(e.getMessage().indexOf("DUPLICATE-MOBILE") != -1)  // DUPLICATE-MOBILE
            data.put("status", "DUPLICATE-MOBILE");
        else if(e.getMessage().indexOf("Field Error :") != -1) { 
            data.put("status", "FIELD ERROR" );
        }

    }

    return Response.status(Response.Status.OK).entity(data).build();
}

@GET
@Path("/getFamilyMemberListForDisplay")
@Produces(MediaType.APPLICATION_JSON)
public Response ***@***.***(value = "hofId") Long hofId) {

    Map<String, Object> data = new HashMap<String, Object>();
    Map<String, Object> membersData = new HashMap<String, Object>();
    try {
        membersData = service.getFamilyMemberListForDisplay(hofId);
        data.put("status", "Success");
        data.put("memberList", membersData.get("memberList"));
        data.put("totalNoOfMemberOfFamily", membersData.get("totalNoOfMemberOfFamily"));
        data.put("noOfMemberHavingLand", membersData.get("noOfMemberHavingLand"));

    } catch (Exception e) {
        data.put("status", "Fail");
        data.put("msg", e.getMessage());
        if(e.getMessage().indexOf("No member found") != -1)
            data.put("status", "NO-DATA-FOUND");
        e.printStackTrace();
    }

    return Response.status(Response.Status.OK).entity(data).build();
}

@GET
@Path("/deleteFamilyMember")
public Response ***@***.***("hofId") Long hofId, @QueryParam("memberId") Long memberId) {
    Map<String, Object> data = new HashMap<String, Object>();
    try {
        service.deleteFamilyMember(hofId, memberId);
        data.put("status", "success");
    } catch (Exception e) {
        data.put("status", "fail");
        data.put("msg", e.getMessage());
    }
    return Response.status(Response.Status.OK).entity(data).build();
}

@GET
@Path("/fetchFamilyMemberDetailsForEdit")
public Response ***@***.***("hofId") Long hofId, @QueryParam("memberId") Long memberId) {
    Map<String, Object> data = new HashMap<String, Object>();
    try {
        data = service.fetchFamilyMemberDetailsForEdit(hofId, memberId);
        data.put("status", "success");
    } catch (Exception e) {
        data.put("status", "fail");
        data.put("msg", e.getMessage());
        e.printStackTrace();        }
    return Response.status(Response.Status.OK).entity(data).build();
}

}

spericas commented 2 years ago

Re-formatted


package com.enrollmentservice.controller;

import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.transaction.Transactional;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.glassfish.jersey.media.multipart.BodyPartEntity;
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
import org.glassfish.jersey.media.multipart.FormDataParam;

import com.enrollmentservice.beans.AddMemberMemberBean;
import com.enrollmentservice.model.AddMember_MemberDetails;
import com.enrollmentservice.model.FamilyMember;
import com.enrollmentservice.service.AddFamilyMemberService;
import com.enrollmentservice.service.BasicDetailsService;
import com.enrollmentservice.service.EmitraService;
import com.enrollmentservice.service.OtpService;
import com.enrollmentservice.util.AadhaarValidator;
import com.enrollmentservice.util.BlurImageValidator;
import com.enrollmentservice.util.FileStorage;

@Path("/enrollment")
@RequestScoped
public class AddFamilyMemberController {

    @Inject
    private FileStorage storage;

    @Inject
    AddFamilyMemberService service;

    @Inject
    private OtpService otpService;

    @Inject
    private BlurImageValidator validator;

    @GET
    @Transactional(Transactional.TxType.REQUIRED)
    @Path("/generateOTPToValidateMobileOfMember")
    public Response ***@***.***(value = "mobileNumber") String mobileNumber) {
        String otpResponse = null;
        Map<String, String> data = new HashMap<String, String>();
        try {
            if (mobileNumber == null)
                throw new Exception("Mobile number not found");

            otpResponse = otpService.generateOtp(mobileNumber);
            data.put("mobileNumber", mobileNumber);
            data.put("otpResponse", otpResponse);
            data.put("status", "success");
        } catch (Exception e) {
            data.put("status", "fail");
            data.put("msg", e.getMessage());
        }

        return Response.status(Response.Status.OK)
                  .entity(data)
                  .build();
    }

    @GET
    @Path(value = "/verifyOTPToValidateFamilyMemberMobileNumber")
    @Produces(MediaType.APPLICATION_JSON)
    public Response ***@***.***("mobileNumber") String mobileNumber,
            @QueryParam("otp") String otp) {

        Map<String, String> response = new HashMap<>();
        boolean flag = false;       
        try {
            flag = otpService.isValidOtp(mobileNumber, otp);
            if(flag) {
                response.put("status", "success");
            }else {
                response.put("status", "fail");
                response.put("msg", "Invalid OTP");
            }
        } catch (Exception e) {
            response.put("status", "error");
            response.put("msg", e.getMessage());
            e.printStackTrace();
        }

        return Response.status(Response.Status.OK)
                  .entity(response)
//                .header("Access-Control-Allow-Origin", "*")
                  .build();
    }

    @POST
    @Path("/fetchDataFromSignUpForEnrollment")
    @Produces(MediaType.APPLICATION_JSON)
    public Response ***@***.***(value = "username") String username) {

        Map<String, Object> data = new HashMap<String, Object>();

        try {
            Map<String, Object> details = service.fetchDataFromSignUpForEnrollment(username);
            data.put("status", "Success");
            data.put("details", details);
        } catch (Exception e) {
            data.put("status", "Fail");
            data.put("msg", e.getMessage());
            if(e.getMessage().indexOf("No member found") != -1)
                data.put("status", "NO-DATA-FOUND");
            e.printStackTrace();
        }

        return Response.status(Response.Status.OK).entity(data).build();
    }

    @POST
    @Path("/addFamilyMemberDetails")
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    @Produces(MediaType.APPLICATION_JSON)
    public Response addFamilyMemberDetails(
            @FormDataParam(value = "user") String  user,
            @FormDataParam(value = "usertype") String  usertype,
            @FormDataParam(value = "hofId") String  hofId,
            @FormDataParam(value = "memberId") String  memberId,
            @FormDataParam(value = "adhaar_number") String  adhaar_number,
            @FormDataParam(value = "firstNameEng") String  firstNameEng, 
            @FormDataParam(value = "middleNameEng") String  middleNameEng, 
            @FormDataParam(value = "lastNameEng") String  lastNameEng, 
            @FormDataParam(value = "gender") String  gender,
            @FormDataParam(value = "dob") String  dob,
            @FormDataParam(value = "age") String  age,
            @FormDataParam(value = "isMemberOrphan") String  isMemberOrphan,
            @FormDataParam(value = "guardianNameEng") String  guardianNameEng,
            @FormDataParam(value = "fatherNameEng") String  fatherNameEng,
            @FormDataParam(value = "motherNameEng") String  motherNameEng,
            @FormDataParam(value = "casteCategory") String  casteCategory, 
            @FormDataParam(value = "caste") String  caste, 
            @FormDataParam(value = "isSpecialAbled") String  isSpecialAbled, 
            @FormDataParam(value = "specialAbledCertificateNo") String  specialAbledCertificateNo, 
            @FormDataParam(value = "specialAbledType") String  specialAbledType, 
            @FormDataParam(value = "percentageOfDisability") String  percentageOfDisability,
            @FormDataParam(value = "maritalStatus") String  maritalStatus, 
            @FormDataParam(value = "spouseNameEng") String  spouseNameEng, 
            @FormDataParam(value = "bloodGroup") String  bloodGroup, 
            @FormDataParam(value = "religion") String  religion, 
            @FormDataParam(value = "mobileNumber") String  mobileNumber, 
            @FormDataParam(value = "email") String  email, 
            @FormDataParam(value = "eductaionalLevel") String  eductaionalLevel,
            @FormDataParam(value = "occupation") String  occupation,
            @FormDataParam(value = "govtEmpId") String  govtEmpId,
            @FormDataParam(value = "ssppo") String  ssppo,
            @FormDataParam(value = "ddoNo") String  ddoNo, 
            @FormDataParam(value = "realIncome") String  realIncome,
            @FormDataParam(value = "artistType") String  artistType,
            @FormDataParam(value = "artistDescription") String  artistDescription,
            @FormDataParam(value = "ifsccode") String  ifsccode, 
            @FormDataParam(value = "bankId") String  bankId, 
            @FormDataParam(value = "bankName") String  bankName, 
            @FormDataParam(value = "bankBranchId") String  bankBranchId,
            @FormDataParam(value = "branchName") String  branchName,
            @FormDataParam(value = "bankAccountNumber") String  bankAccountNumber,
            @FormDataParam(value = "panNo") String  panNo, 
            @FormDataParam(value = "drivingLicenseNo") String  drivingLicenseNo,
            @FormDataParam(value = "passportNo") String  passportNo,
            @FormDataParam(value = "voterIdNo") String  voterIdNo,
            @FormDataParam(value = "labourCardNo") String  labourCardNo, 
            @FormDataParam(value = "labourCardExpiryDate") String  labourCardExpiryDate,
            @FormDataParam(value = "mngregaCardNo") String  mngregaCardNo,
            @FormDataParam(value = "farmerId") String  farmerId,
            @FormDataParam(value = "landowner") String  landowner,
            @FormDataParam(value = "photo") FormDataBodyPart  photo 
            ) {

        Map<String, Object> data = new HashMap<String, Object>();
        FamilyMember member = new FamilyMember();

        AadhaarValidator av = null;

        Response response = null;

        try {
            member.setUser(user);
            member.setUsertype(usertype);           
            try {
                member.setHofId(Long.valueOf(hofId));
            } catch (Exception e) {
//              e.printStackTrace();
            }
            try {
                member.setMemberId(Long.valueOf(memberId));
            } catch (Exception e) {
//              e.printStackTrace();
            }
            try {
                member.setAdhaar_number(Long.valueOf(adhaar_number));
            } catch (Exception e) {
//              e.printStackTrace();
            }
            member.setFirstNameEng(firstNameEng);
            member.setMiddleNameEng(middleNameEng);
            member.setLastNameEng(lastNameEng);
            try {
                member.setGender(Long.valueOf(gender));
            } catch (Exception e) {
//              e.printStackTrace();
            }
            member.setDob(dob);
            try {
                member.setAge(Integer.valueOf(age));
            } catch (Exception e) {
//              e.printStackTrace();
            }
            member.setIsMemberOrphan(isMemberOrphan);
            member.setGuardianNameEng(guardianNameEng);
            member.setFatherNameEng(fatherNameEng);
            member.setMotherNameEng(motherNameEng);
            try {
                member.setCasteCategory(Integer.valueOf(casteCategory));
            } catch (Exception e) {
//              e.printStackTrace();
            }
            try {
                member.setCaste(Integer.valueOf(caste));
            } catch (Exception e) {
//              e.printStackTrace();
            }
            member.setIsSpecialAbled(isSpecialAbled);
            member.setSpecialAbledCertificateNo(specialAbledCertificateNo);
            member.setSpecialAbledType(specialAbledType);

            try {
                member.setPercentageOfDisability(String.valueOf(Long.valueOf(percentageOfDisability)));
            } catch (Exception e) {
//              e.printStackTrace();
            }
            try {
                member.setMaritalStatus(Long.valueOf(maritalStatus));
            } catch (Exception e) {
//              e.printStackTrace();
            }
            member.setSpouseNameEng(spouseNameEng);
            try {
                member.setBloodGroup(Integer.valueOf(bloodGroup));
            } catch (Exception e1) {
//              e1.printStackTrace();
            }
            try {
                member.setReligion(Integer.valueOf(religion));
            } catch (Exception e1) {
//              e1.printStackTrace();
            }
            try {
                member.setMobileNumber(Long.valueOf(mobileNumber));
            } catch (Exception e) {
//              e.printStackTrace();
            }
            member.setEmail(email);
            try {
                member.setEductaionalLevel(Long.valueOf(eductaionalLevel));
            } catch (Exception e) {
//              e.printStackTrace();
            }
            try {
                member.setOccupation(Long.valueOf(occupation));
            } catch (Exception e) {
//              e.printStackTrace();
            }
            member.setGovtEmpId(govtEmpId);
            member.setSsppo(ssppo);
            member.setDdoNo(ddoNo);
            try {
                member.setRealIncome(Long.valueOf(realIncome));
            } catch (Exception e) {
//              e.printStackTrace();
            }
            try {
                member.setArtistType(Long.valueOf(artistType));
            } catch (Exception e) {
//              e.printStackTrace();
            }
            member.setArtistDescription(artistDescription);
            member.setIfsccode(ifsccode);
            try {
                member.setBankId(Long.valueOf(bankId));
            } catch (Exception e) {
//              e.printStackTrace();
            }
            member.setBankName(bankName);
            try {
                member.setBankBranchId(Long.valueOf(bankBranchId));
            } catch (Exception e) {
//              e.printStackTrace();
            }
            member.setBranchName(branchName);
            member.setBankAccountNumber(bankAccountNumber);
            member.setPanNo(panNo);
            member.setDrivingLicenseNo(drivingLicenseNo);
            member.setPassportNo(passportNo);
            member.setVoterIdNo(voterIdNo);
            member.setLabourCardNo(labourCardNo);
//          member.setLabourCardExpiryDate(labourCardExpiryDate);
            member.setMngregaCardNo(mngregaCardNo);
            member.setFarmerId(farmerId);
            try {
                member.setLandowner(Integer.valueOf(landowner));
            } catch (Exception e) {
                e.printStackTrace();
            }
            if(photo == null) 
                throw new Exception("Photo mandetory");
            member.setPhoto(photo);

            // Validate Photo For Blurring starts
            String timeStamp = String.valueOf(new Date().getTime());

            java.nio.file.Path location=storage.create(member.getPhoto().getContentDisposition().getFileName()+timeStamp);

            boolean flag=true;

            System.out.println("Starting ImageValidationController Controller..........");

            Files.copy(member.getPhoto().getEntityAs(BodyPartEntity.class).getInputStream(),
                    location,
                    StandardCopyOption.REPLACE_EXISTING);

            String path=location.toString();

//          flag=validator.validateBlurImage(path);

            Files.delete(location);

            if(flag == false)
                throw new Exception("Blur Image");

            // Validation of photo ends

            System.out.println(member.toString());

            Map<String, Object> validationResult = service.isValidData(member);
            if(((String)validationResult.get("validation-status")).equalsIgnoreCase("fail")) {
                data.put("status", "INVALID-FIELD");
                data.put("fieldName", (String)validationResult.get("fieldName"));   
                data.put("msg", (String)validationResult.get("msg"));
            }else {
                if (member.getAdhaar_number()== null || av.isValidAadhaarNo(member.getAdhaar_number())) {
                    member = service.addFamilyMemberDetails(member);
                    System.out.println("adhar number:" + member.getAdhaar_number());
                    data.put("status", "SUCCESS");

                } else {
                    data.put("status", "VALIDATION_FAIL");
                    data.put("msg", "Invalid aadhar number");
                }
            }

        }catch (Exception e) {
            e.printStackTrace();
            data.put("status", "FAIL");
            data.put("msg", e.getMessage());
            if(e.getMessage() == null)
                data.put("msg", "Null pointer exception");
            else if(e.getMessage().indexOf("ConstraintViolationException") != -1)
                data.put("status", "DUPLICATE-AADHAAR");
            else if(e.getMessage().indexOf("Photo mandetory") != -1)
                data.put("status", "INVALID-PHOTO");
            else if(e.getMessage().indexOf("File can not be converted to clob") != -1)
                data.put("status", "PHOTO-READ-FAIL");
            else if(e.getMessage().indexOf("Blur Image") != -1)
                data.put("status", "BLUR-PHOTO");
            else if(e.getMessage().indexOf("DUPLICATE-MOBILE") != -1)  // DUPLICATE-MOBILE
                data.put("status", "DUPLICATE-MOBILE");
            else if(e.getMessage().indexOf("Field Error :") != -1) { 
                data.put("status", "FIELD ERROR" );
            }

        }

        return Response.status(Response.Status.OK).entity(data).build();
    }

    @GET
    @Path("/getFamilyMemberListForDisplay")
    @Produces(MediaType.APPLICATION_JSON)
    public Response ***@***.***(value = "hofId") Long hofId) {

        Map<String, Object> data = new HashMap<String, Object>();
        Map<String, Object> membersData = new HashMap<String, Object>();
        try {
            membersData = service.getFamilyMemberListForDisplay(hofId);
            data.put("status", "Success");
            data.put("memberList", membersData.get("memberList"));
            data.put("totalNoOfMemberOfFamily", membersData.get("totalNoOfMemberOfFamily"));
            data.put("noOfMemberHavingLand", membersData.get("noOfMemberHavingLand"));

        } catch (Exception e) {
            data.put("status", "Fail");
            data.put("msg", e.getMessage());
            if(e.getMessage().indexOf("No member found") != -1)
                data.put("status", "NO-DATA-FOUND");
            e.printStackTrace();
        }

        return Response.status(Response.Status.OK).entity(data).build();
    }

    @GET
    @Path("/deleteFamilyMember")
    public Response ***@***.***("hofId") Long hofId, @QueryParam("memberId") Long memberId) {
        Map<String, Object> data = new HashMap<String, Object>();
        try {
            service.deleteFamilyMember(hofId, memberId);
            data.put("status", "success");
        } catch (Exception e) {
            data.put("status", "fail");
            data.put("msg", e.getMessage());
        }
        return Response.status(Response.Status.OK).entity(data).build();
    }

    @GET
    @Path("/fetchFamilyMemberDetailsForEdit")
    public Response ***@***.***("hofId") Long hofId, @QueryParam("memberId") Long memberId) {
        Map<String, Object> data = new HashMap<String, Object>();
        try {
            data = service.fetchFamilyMemberDetailsForEdit(hofId, memberId);
            data.put("status", "success");
        } catch (Exception e) {
            data.put("status", "fail");
            data.put("msg", e.getMessage());
            e.printStackTrace();        }
        return Response.status(Response.Status.OK).entity(data).build();
    }

}```
spericas commented 2 years ago

Any ideas @ljnelson ?

ljnelson commented 2 years ago

The OP has reported this issue using many different channels and the root cause is a problem with an understanding of how to do stored procedure queries in JPA that return lists of things. I have in other channels pointed the OP at a JPA stored procedure tutorial that seems to be directly concerned with the area of the API they're trying to use.

ljnelson commented 2 years ago

Closing since this has been addressed in other channels