Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7937131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:26:42+00:00 2026-06-03T22:26:42+00:00

This JPQL used to work but then it broke for no reason. I now

  • 0

This JPQL used to work but then it broke for no reason. I now get this strange exception:

java.lang.IllegalArgumentException: Parameter "Parameter<LandKod>('landKod')" declared in "SELECT r FROM Region r WHERE r.landKod = :landKod" is set to value of "US" of type "java.lang.String", but this parameter is bound to a field of type "se.prv.pandora.arendeprocess.entity.LandKod".

which seems to indicate that there is some kind of name conflict of what is named landKod in my code. Here is the source:

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@Entity(name = "Region")
@Table(name="TP197_REGION")

@NamedQueries({
    @NamedQuery(name = "getAllValidRegions", query = "SELECT r FROM Region r WHERE r.histKod = 'A'"), 
    @NamedQuery(name = "getRegionsByLandkod", query = "SELECT r FROM Region r WHERE r.landKod = :landKod")
})

public class Region implements Serializable {

    @Id
    private int regionId;

    @ManyToOne
    @JoinColumn(name="landKod", referencedColumnName="landKod")
    private LandKod landKod ;

    private String histKod ;
    private String regionForkort;
    private String regionRubrik;
    private String regionBeskr;

    public Region() {
        super();
    }


    public int getRegionId() {
        return regionId;
    }


    public void setRegionId(int regionId) {
        this.regionId = regionId;
    }


    public String getRegionForkort() {
        return regionForkort;
    }

    public void setRegionForkort(String regionForkort) {
        this.regionForkort = regionForkort;
    }

    public String getRegionRubrik() {
        return regionRubrik;
    }

    public void setRegionRubrik(String regionRubrik) {
        this.regionRubrik = regionRubrik;
    }

    public String getRegionBeskr() {
        return regionBeskr;
    }

    public void setRegionBeskr(String regionBeskr) {
        this.regionBeskr = regionBeskr;
    }


    public String getHistKod() {
        return histKod;
    }


    public void setHistKod(String histKod) {
        this.histKod = histKod;
    }


    public String getRegionFormatted() {
        if(regionForkort!=null && regionForkort.length()>0) {
            return regionForkort + " " + regionRubrik;
        } else {
            return regionRubrik;

        }
    }


    public LandKod getLandKod() {
        return landKod;
    }


    public void setLandKod(LandKod landKod) {
        this.landKod = landKod;
    }


}

Here’s the method implementation where it allows a string as a parameter:

@Override
public List<Region> getRegionsByLandkod(String landKod) {

    List<Region> regionsList = null;


try {

    Query query = em.createNamedQuery("getRegionsByLandkod");
    query.setParameter("landKod", landKod);
    regionsList =  (List<Region>) query.getResultList();

} catch(Exception e){ 
    logger.info("Kunde inte hitta någon region med landkod: "+landKod, e);
}

return regionsList;
}

Could you help me fix this error?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T22:26:43+00:00Added an answer on June 3, 2026 at 10:26 pm

    It seems you’re calling getRegionsByLandkod with a String instead of a LandKod object.
    Verify where you use this query if the parameter is correct.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I´m trying to get accustomed to JPQL, but i´m already stuck. How does this:
I can't find out why throw this expression always a NullPointerException: String jpql =
I'm wondering if there is any JPQL construct that might help me with this
In hibernate I want to run this JPQL / HQL query: select new org.test.userDTO(
I'm sure I'm being stupid but I can't seem to figure this one out...
I have created a JPQL like this: select sum(c.field1) field1, sum(c.field2) field2, sum(c.field3) field3
I want to make a JPQL query with a collection of non entities. This
I need to convert this self join to JPQL: SELECT s1.* FROM site AS
How can i write this sql in jpql syntax? SELECT SUM(t1.preise) FROM ( SELECT
This is my simple JPQL: SELECT s FROM Site s GROUP BY s.siteType siteResult

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.