当前位置: 首页 > 知识库问答 >
问题:

自动连接依赖项的注入失败BeanCreationException

司马俊晖
2023-03-14

大家好,我收到下一个错误,我是使用Hibernate的新手

    package ar.com.lakaut.sig.core.service;
import ar.com.lakaut.sig.core.domain.SoftwareVersion;
import com.curcico.jproject.core.services.BaseAuditedEntityService;
import com.curcico.jproject.core.exception.BaseException;
public interface SoftwareVersionService extends BaseAuditedEntityService<SoftwareVersion>{

    public SoftwareVersion getSoftwareVersion(String name) throws BaseException;

    public SoftwareVersion getSoftwareVersion(Integer id) throws BaseException;

    public void addSoftwareVersion(SoftwareVersion softwareVersion) throws BaseException;

    public void updateSoftwareVersion(SoftwareVersion oldSoftwareVersion, SoftwareVersion newSoftwareVersion) throws BaseException;

    public void deleteSoftwareVersion(SoftwareVersion softwareVersion) throws BaseException;
}
package ar.com.lakaut.sig.core.dao;

import com.curcico.jproject.core.daos.BaseAuditedEntityDao;
import com.curcico.jproject.core.exception.BaseException;
import com.curcico.jproject.core.exception.InternalErrorException;
import ar.com.lakaut.sig.core.domain.SoftwareVersion;

public interface SoftwareVersionDao  extends BaseAuditedEntityDao<SoftwareVersion>{

    SoftwareVersion getSoftwareVersion(Integer id, boolean users) throws InternalErrorException;

    SoftwareVersion getSoftwareVersion(Integer id) throws InternalErrorException;

    SoftwareVersion getSoftwareVersion(String sft_product_name) throws InternalErrorException;

    String getNextSoftwareVersionBarcodePrefix() throws BaseException;
}

package ar.com.lakaut.sig.core.dao;


import ar.com.lakaut.sig.core.domain.SoftwareVersion;
import com.curcico.jproject.core.daos.ConditionEntry;
import com.curcico.jproject.core.daos.ManagerAlias;
import com.curcico.jproject.core.daos.ManagerFetchs;
import com.curcico.jproject.core.exception.BaseException;
import com.curcico.jproject.core.exception.InternalErrorException;
import com.curcico.jproject.core.wrapper.GridWrapper;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.SessionFactory;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.curcico.jproject.core.daos.BaseAuditedEntityDaoImpl;



public class SoftwareVersionDaoImpl extends BaseAuditedEntityDaoImpl<SoftwareVersion> implements SoftwareVersionDao {

    public SoftwareVersionDaoImpl() {  }

    @Override
    public SoftwareVersion getSoftwareVersion(Integer id, boolean users) throws InternalErrorException {
        return null;
    }

    @Override
    public SoftwareVersion getSoftwareVersion(Integer id) throws InternalErrorException {
        return null;
    }
    public SoftwareVersion getSoftwareVersion(String sft_product_name) throws InternalErrorException {
        logger.debug("getLastKia-DesktopSoftwareVersion");
        String sql = "select" + "* from sig_versions where sft_product_name like 'kiadoc-desktop' order by created_date DESC limit 1";
        Query query = this.sessionFactory.getCurrentSession().createSQLQuery(sql);
        List result = query.list();
        SoftwareVersion softwareVersion = new SoftwareVersion();
        softwareVersion.set_Version(result.get(0).toString());
        return null;
    }

    @Override
    public String getNextSoftwareVersionBarcodePrefix() throws BaseException {
        return null;
    }

    @Override
    public SoftwareVersion update(SoftwareVersion object, Integer user) throws BaseException {
        return null;
    }

    @Override
    public SoftwareVersion save(SoftwareVersion object, Integer user) throws BaseException {
        return null;
    }

    @Override
    public SoftwareVersion saveOrUpdate(SoftwareVersion object, Integer user) throws BaseException {
        return null;
    }

    @Override
    public SoftwareVersion delete(SoftwareVersion object, Integer user) throws BaseException {
        return null;
    }

    @Override
    public SoftwareVersion loadEntityById(Integer id) throws BaseException {
        return null;
    }

    @Override
    public SoftwareVersion loadEntityById(Integer id, Set<ManagerFetchs> fetchs) throws BaseException {
        return null;
    }

    @Override
    public SoftwareVersion loadEntityByFilters(List<ConditionEntry> filters) throws BaseException {
        return null;
    }

    @Override
    public SoftwareVersion loadEntityByFilters(List<ConditionEntry> filters, Set<ManagerFetchs> fetchs) throws BaseException {
        return null;
    }

    @Override
    public Long count() throws BaseException {
        return null;
    }

    @Override
    public Collection<? extends SoftwareVersion> findAll() throws BaseException {
        return null;
    }

    @Override
    public Collection<? extends SoftwareVersion> findAll(Integer numeroDePagina, Integer tamanioPagina) throws BaseException {
        return null;
    }

    @Override
    public Collection<? extends SoftwareVersion> findAll(String orderBy, String orderMode) throws BaseException {
        return null;
    }

    @Override
    public Collection<? extends SoftwareVersion> findAll(Integer numeroDePagina, Integer tamanioPagina, String orderBy, String orderMode) throws BaseException {
        return null;
    }

    @Override
    public List<Integer> getIds() throws BaseException {
        return null;
    }

    @Override
    public Long countByFilters(List<ConditionEntry> conditions) throws BaseException {
        return null;
    }

    @Override
    public Long countByFilters(Criteria criteria, List<ConditionEntry> filters) throws BaseException {
        return null;
    }

    @Override
    public Collection<? extends SoftwareVersion> findByFilters(List<ConditionEntry> conditions) throws BaseException {
        return null;
    }

    @Override
    public Collection<? extends SoftwareVersion> findByFilters(List<ConditionEntry> filters, Set<ManagerFetchs> fetchs) throws BaseException {
        return null;
    }

    @Override
    public Collection<? extends SoftwareVersion> findByFilters(List<ConditionEntry> conditions, Integer numeroDePagina, Integer tamanioPagina, String orderBy, String orderMode, Set<ManagerFetchs> fetchs) throws BaseException {
        return null;
    }

    @Override
    public Collection<? extends SoftwareVersion> findByFilters(Criteria criteria, List<ConditionEntry> filters, Integer page, Integer rows, String orderBy, String orderMode, Set<ManagerFetchs> fetchs) throws BaseException {
        return null;
    }

    @Override
    public GridWrapper<? extends SoftwareVersion> findByFiltersGridWrapper(List<ConditionEntry> filters, Integer page, Integer rows, String orderBy, String orderMode, Set<ManagerFetchs> fetchs) throws BaseException {
        return null;
    }

    @Override
    public Set<ManagerAlias> getAlias() {
        return null;
    }

    @Override
    public Set<ManagerFetchs> getFetchs() {
        return null;
    }

    @Override
    public SessionFactory getSessionFactory() {
        return null;
    }

    @Override
    public List<List<String>> getContentReportGeneric(String sql, Map<String, Object> param, List<String> fieldSelect) {
        return null;
    }

    @Override
    public Criteria getCriteria() throws BaseException {
        return null;
    }

    @Override
    public Criteria getCriteria(String alias) throws BaseException {
        return null;
    }
}
package ar.com.lakaut.sig.core.service;

import ar.com.lakaut.sig.core.domain.SoftwareVersion;
import com.curcico.jproject.core.exception.BaseException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.curcico.jproject.core.services.BaseAuditedEntityServiceImpl;
import ar.com.lakaut.sig.core.dao.SoftwareVersionDao;
import org.apache.log4j.Logger;

@Service("softwareVersionService")
public class SoftwareVersionServiceImpl extends BaseAuditedEntityServiceImpl<SoftwareVersion, SoftwareVersionDao> implements SoftwareVersionService {

    Logger logger = Logger.getLogger(SoftwareVersionServiceImpl.class);

    @Autowired
    private SoftwareVersionDao softwareVersionDao;


    @Override
    public SoftwareVersion getSoftwareVersion(Integer id) throws BaseException {
        logger.info("softwareVersionId: " + id);
        return softwareVersionDao.getSoftwareVersion(id);
    }

    @Override
    public SoftwareVersion getSoftwareVersion(String sft_product_name) throws BaseException {
        logger.info("softwareVersionId: " + sft_product_name);
        return softwareVersionDao.getSoftwareVersion(sft_product_name);
    }

    @Override
    public void addSoftwareVersion(SoftwareVersion softwareVersion) throws BaseException {

    }

    @Override
    public void updateSoftwareVersion(SoftwareVersion oldSoftwareVersion, SoftwareVersion newSoftwareVersion) throws BaseException {

    }

    @Override
    public void deleteSoftwareVersion(SoftwareVersion softwareVersion) throws BaseException {

    }

    @Override
    public SoftwareVersion update(SoftwareVersion object, Integer user) throws BaseException {
        return null;
    }

    @Override
    public SoftwareVersion save(SoftwareVersion object, Integer user) throws BaseException {
        return null;
    }

    @Override
    public SoftwareVersion saveOrUpdate(SoftwareVersion object, Integer user) throws BaseException {
        return null;
    }

    @Override
    public SoftwareVersion delete(SoftwareVersion object, Integer user) throws BaseException {
        return null;
    }
}
package ar.com.lakaut.sig.core.domain;

import com.curcico.jproject.core.entities.BaseAuditedEntity;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.io.Serializable;

@Entity
@Table(name = "sig_versions")
@SQLDelete(sql="UPDATE sig_versions SET deleted = '1' WHERE version_id = ? and version = ?")
@Where(clause="deleted is null")
public class SoftwareVersion extends BaseAuditedEntity implements Serializable {

    public SoftwareVersion() {}

    private String product_name;
    private String sft_version;
    private String obs;

    public SoftwareVersion(String product_name, String version, String obs, Integer created_user, Integer updated_user) {
        super();
        this.id = id;
        this.product_name = product_name;
        this.sft_version = version;
        this.obs = obs;
    }

    public SoftwareVersion(Integer id){
            super();
            setId(id);
    }

    public void setProduct_name(String product_name) {
        this.product_name = product_name;
    }

    @Id
    @SequenceGenerator(name = "id_generator", sequenceName = "sig_versions_config_seq", allocationSize = 1)
    @GeneratedValue(generator = "id_generator", strategy =GenerationType.SEQUENCE)
    @Column(name = "sft_id", unique = true, nullable = false)
    public Integer getId() { return this.id; }

    @Column(name = "sft_product_name", nullable = false)
    public String getProductName() { return product_name; }

    public void setProductName(String product_name) { this.product_name = product_name; }

    @Column(name = "sft_version", nullable = false)
    public String get_Version() { return sft_version; }

    public void set_Version(String version) { this.sft_version = version; }

    @Column(name = "sft_obs", nullable = false)
    public String getObs() { return obs; }

    public void setObs(String obs) { this.obs = obs; }
}

共有1个答案

贝洲
2023-03-14

谢谢你们的帮助。我已经这样解决了。

@Repository

public class SoftwareVersionDaoImpl extends BaseAuditedEntityDaoImpl<SoftwareVersion> implements SoftwareVersionDao {
public class SoftwareVersionDaoImpl extends BaseAuditedEntityDaoImpl<SoftwareVersion> implements SoftwareVersionDao {


public SoftwareVersionDaoImpl() {  }
public SoftwareVersionDaoImpl() { super(); }

我已经添加了@Repository注释和super();构造器

 类似资料: