Search code examples
springjpajavabeansjpqlcuba-platform

Bound mismatch for Collectiondatasource working


@Inject

private CollectionDatasource<Scheme, UUID> schemesDs;

I am trying to instantiate the collection datasource for scheme datasource

I am receiving this error on Eclipse as an error

Bound mismatch: The type Scheme is not a valid substitute for the bounded parameter > of the type CollectionDatasource

This is the entity for Scheme

@Inject

private CollectionDatasource<Scheme, UUID> schemesDs;


Here is the Scheme Entity Class.


/*

* Copyright (c) 2016 water-scheme-nigeria

*/

package com.company.waterschemenigeria.entity;


import javax.persistence.Entity;

import javax.persistence.Table;

import javax.persistence.Column;

import com.haulmont.cuba.core.entity.BaseIntegerIdEntity;

import com.haulmont.chile.core.annotations.NamePattern;

import javax.persistence.FetchType;

import javax.persistence.JoinColumn;

import javax.persistence.OneToOne;


/**

* @author samuel.thampy

*/

@NamePattern("%s|locationName")

@Table(name = "WATERSCHEMENIGERIA_SCHEME")

@Entity(name = "waterschemenigeria$Scheme")

public class Scheme extends BaseIntegerIdEntity {

private static final long serialVersionUID = -5886267876250540580L;


@OneToOne(fetch = FetchType.LAZY)

@JoinColumn(name = "LOCATION_NAME_ID")

protected Location locationName;


@Column(name = "WATERSCHEME", nullable = false)

protected String waterscheme;


@Column(name = "CAPACITY")

protected Double capacity;


@Column(name = "STATUS", nullable = false)

protected String status;


public void setLocationName(Location locationName) {

this.locationName = locationName;

}


public Location getLocationName() {

return locationName;

}



public void setWaterscheme(WaterScheme waterscheme) {

this.waterscheme = waterscheme == null ? null : waterscheme.getId();

}


public WaterScheme getWaterscheme() {

return waterscheme == null ? null : WaterScheme.fromId(waterscheme);

}


public void setStatus(Status status) {

this.status = status == null ? null : status.getId();

}


public Status getStatus() {

return status == null ? null : Status.fromId(status);

}



public void setCapacity(Double capacity) {

this.capacity = capacity;

}


public Double getCapacity() {

return capacity;

}
}

Solution

  • You datasource field should look like this:

    @Inject
    private CollectionDatasource<Schema, Integer> schemasDs;
    

    The Scheme entity extends BaseIntegerIdEntity, so its primary key type is Integer, not UUID.