Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hibernate generic dao overloading method (removeById) #117

Open
alexshemesh opened this issue Apr 4, 2016 · 0 comments
Open

hibernate generic dao overloading method (removeById) #117

alexshemesh opened this issue Apr 4, 2016 · 0 comments

Comments

@alexshemesh
Copy link

0
down vote
favorite
Im implementing hibernate ORM in my java project. Ive downloaded source from github Ive compiled hibernate-maven-web included in samples. Now lets assume i want to overload method in one of the implementations For example CitizenDAOImpl.java Before my changes it looked like that.

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 {


}

All i did was override removeById that would just call super class. Later on im planing to add some ecrypt functionality so id will all be scrambled.

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(Long id) {
        return super.removeById(id);
    }
}

when i run mvn clean install it gives me error

[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

I understand that its ambiguous call and both BaseDAO and CitizenDAO do inherit GenericADO at some point. What is good solution in this case? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant