0
私のJavaプロジェクトでhibernate ORMを実装しています。 Iveがソースをダウンロードしましたgithub サンプルに含まれているIveがコンパイルされたhibernate-maven-web。 ここでは、実装の1つでメソッドをオーバーロードしたいと仮定します。 例:CitizenDAOImpl.java 変更前は、そのように見えました。hibernate generic dao overloading removeById
package sample.googlecode.genericdao.oldworld.dao;
import org.springframework.stereotype.Repository;
import sample.googlecode.genericdao.oldworld.model.Citizen;
/**
* <p>
* This is the implementation of the Citizen DAO. You can see that we don't
* actually have to implement anything, it is all inherited from GenericDAOImpl
* through BaseDAO. We just specify the entity type (Citizen) and its identifier
* type (Long).
*
* <p>
* The @Repository allows Spring to recognize this as a managed component (so we
* don't need to specify it in XML) and also tells spring to do DAO exception
* translation to the Spring exception hierarchy.
*
* @author dwolverton
*
*/
@Repository
public class CitizenDAOImpl extends BaseDAO<Citizen, Long> implements CitizenDAO {
}
私がしたすべては、ちょうどスーパークラスを呼び出すだろうとremoveByIdを上書きしました。 その後、ecrypt機能を追加しようとしていますので、idはすべてスクランブルされます。私はをMVNクリーンインストールを実行するとき
package sample.googlecode.genericdao.oldworld.dao;
import org.springframework.stereotype.Repository;
import sample.googlecode.genericdao.oldworld.model.Citizen;
/**
* <p>
* This is the implementation of the Citizen DAO. You can see that we don't
* actually have to implement anything, it is all inherited from GenericDAOImpl
* through BaseDAO. We just specify the entity type (Citizen) and its identifier
* type (Long).
*
* <p>
* The @Repository allows Spring to recognize this as a managed component (so we
* don't need to specify it in XML) and also tells spring to do DAO exception
* translation to the Spring exception hierarchy.
*
* @author dwolverton
*
*/
@Repository
public class CitizenDAOImpl extends BaseDAO<Citizen, Long> implements CitizenDAO {
@Override
public boolean removeById(java.io.Serializable id) {
return super.removeById(id);
}
}
それは私が私がそのあいまいなコールとBaseDAOとCitizenDAO両方がいくつかの点でGenericADOを継承しないことを理解し
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.
1:compile (default-compile) on project hibernate-maven-web: Compilation failure
[ERROR] /C:/Dev/spike/hibernate-maven-web/src/main/java/sample/googlecode/generi
cdao/oldworld/dao/CitizenDAOImpl.java:[26,24] name clash: removeById(java.io.Ser
ializable) in sample.googlecode.genericdao.oldworld.dao.CitizenDAOImpl and remov
eById(ID) in com.googlecode.genericdao.dao.hibernate.GenericDAO have the same er
asure, yet neither overrides the other
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
eption
をエラー与えます。 この場合、良い解決策は何ですか? おかげで