I encountered a strange error related to Java using Intellij Idea.
So there is such interface :
<T> void save(T aEntity, DbTransaction dbTransaction, Class<T> clazz);
<T> void save(Collection<T> aEntities, DbTransaction dbTransaction, Class<T> clazz);
When I try to compile the next code :
@SuppressWarnings("unchecked")
@Override
public void save(Collection<T> aEntities, DbTransaction aDbTransaction) {
baseDao.save(aEntities, aDbTransaction, getClass((T) aEntities.toArray()[0]));
}
I receive the next compilation error :
reference to save is ambiguous, both method <T>save(T,DbEntityHelper.DbTransaction,java.lang.Class<T>) in xzc.dao.IBaseDao and method <T>save(java.util.Collection<T>,DbEntityHelper.DbTransaction,java.lang.Class<T>) in xzc.dao.IBaseDao match
Do you have any ideas ?
Thanks for help in advance.
You have two types called
Tand it can’t assume they are the same.Tcould beCollection<T>in the second method or it could beTin the first.You can use
or
to make it clear which one it should be. Making them the
Tsame name doesn’t help the compiler and may just be confusing.