Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Could not locate appropriate constructor on class : com.recruit.api.model.JobRecruiter; nested exception is java.lang.IllegalArgumentException: Could not locate appropriate constructor on class : com.recruit.api.model.JobRecruiter/500

I added the constructor class but I don't know it is right or not and it shows the above error , and I don't know how to map please share your thoughts, thank you

//ended by dharmateja

What I have tried:

Java
jointerface.java
```
JobRecruiter getDetails(String jobtitle);
```
jobrepository.java
```
@Query(nativeQuery = true)
	JobRecruiter findByJobTitle(@Param("jobTitle")String jobtitle);
```

Table.java
```java
@SqlResultSetMappings({
    @SqlResultSetMapping(
            name = "details",
            classes = {
                    @ConstructorResult(
                            targetClass = TableJobGrabber.class,
                            columns = {
                                   @ColumnResult(name = "jobTitle", type = String.class),
                                   @ColumnResult(name = "recruiterName", type = String.class),
                            }
                    )
            }
    ),

})

@NamedNativeQueries({

    @NamedNativeQuery(name = "TableJobGrabber.findByJobTitle", query = "select job_uploads.recruiter_name as recruiterName,job_uploads.job_title as jobTitle where job_title= :jobTitle", resultSetMapping = "details"),
})

@Entity(name = "job_uploads")
@Table(name = "job_uploads")
public class TableJobGrabber  {
    @Id
    @GeneratedValue
    private int id;
    @Column
    private String jobTitle;

   @Column
    private String recruiterName;
    public String getRecruiterName() {
        return recruiterName;
    }
    public void setRecruiterName(String recruiterName ) {
        this.recruiterName = recruiterName;
    } 
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getJobTitle() {
        return jobTitle;
    }
    public void setJobTitle(String jobTitle) {
        this.jobTitle = jobTitle;
    }

```

constructore.java
```

import java.io.Serializable;

//added by dharmateja
public class JobRecruiter implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 9005185494377577900L;
	private int id;
	private String jobTitle;
	private String recruiterName;
	public JobRecruiter(int id, String jobTitle, String recruiterName) {
		super();
		this.id = id;
		this.jobTitle = jobTitle;
		this.recruiterName = recruiterName;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getJobTitle() {
		return jobTitle;
	}
	public void setJobTitle(String jobTitle) {
		this.jobTitle = jobTitle;
	}
	public String getRecruiterName() {
		return recruiterName;
	}
	public void setRecruiterName(String recruiterName) {
		this.recruiterName = recruiterName;
	}
	
	
}
Posted
Updated 1-Sep-22 4:07am
v2

1 solution

Your constructor is:
Java
public JobRecruiter(int id, String jobTitle, String recruiterName)

So any code that instantiates a JobRecruiter object must pass three parameters. The only lines I can find where it makes such a call are
Java
JobRecruiter getDetails(String jobtitle); // only one parameter
```
jobrepository.java
```
@Query(nativeQuery = true)
	JobRecruiter findByJobTitle(@Param("jobTitle")String jobtitle); // only one parameter

Although I do not know what actual Java code is generated by those statements.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900