problem while create dao for a generic model

7 Aufrufe
Direkt zur ersten ungelesenen Nachricht

niranjan.kr...@itbhu.ac.in

ungelesen,
27.11.2018, 09:44:1127.11.18
an ORMLite Developers
I have 3 classes : Professional, Doctor and Blog as described below-


public class Professional {
}

@DatabaseTable(tableName = "doctors", daoClass = DoctorDao.class)
public class Doctor extends Professional {
@DatabaseField(columnName = "id", generatedId = true)
Long id;

@DatabaseField(columnName = "name")
String name;

public Doctor() {

}
}

@DatabaseTable(tableName = "blogs", daoClass = BlogDao.class)
public class Blog<T> {
@DatabaseField(columnName = "id", generatedId = true)
Long id;

@DatabaseField(columnName = "title")
String title;

@DatabaseField(columnName = "blog_of", foreign = true, canBeNull = false, foreignAutoCreate = true)
T author;
}

I am unable to create DAO for the Blog class as I am not able to call constructor with generic parameter with class Blog.
The DAO for Blog are : 

public interface BlogDaoInterface extends Dao<Blog<? extends Professional>, Long> {
}

public class BlogDao extends BaseDaoImpl<Blog<? extends Professional>, Long> implements BlogDaoInterface {

public BlogDao(ConnectionSource connectionSource) throws SQLException {
super(connectionSource, Blog<? extends Professional>.class);
}
}

ERROR:
The ormlite is not able to create DAO of Blog class(i.e. BlogDao).
I have used ormlite to create tables by the following line of code :

TableUtils.createTableIfNotExists(connectionSource, Blog.class);

But the gradle shows following error:
"cannot select from parametrized type" in the BlogDao class in the following line:
super(connectionSource, Blog<? extends Professional>.class);


Please tell me the correct way of doing it ASAP. I am stuck with this problem for many days and not able to find any solution on internet.
Thanks in advance.
Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten