使用Spring MVC / Hibernate的POSTGRESQL错误,'大对象可能无法在自动提交模式下使用'

问题描述 投票:0回答:2

当然,每个Here这似乎很容易,但是我在应用程序上下文中添加了以下内容...

<property name="dataSource">
    <ref bean="dataSource"/>
</property>

<property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.autocommit">false</prop>
        </props>
    </property>
    <property name="annotatedClasses">
        <list>
            <value>com.gleason.gt.server.model.database.PlayListEntry</value>
            <value>com.gleason.gt.server.model.database.MusicFile</value>
        </list>
    </property>
</bean>

我仍然遇到相同的错误,有什么想法吗?

更新添加服务/ DAO

@Repository("musicFileDao")
public class MusicFileDAOImpl extends GroovyTimeHibernateDAOSupport{
@Transactional()
public MusicFile getMusicFile(Integer i){
    @SuppressWarnings("unchecked")
    List<MusicFile> returnValue = (List<MusicFile>)getHibernateTemplate().find("from MusicFile where id=?",i);
    if(returnValue.size()>0){
        return returnValue.get(0);
    }
    return null;
}
}
@Service("musicFileService")
public class MusicFileService {
@Autowired
private MusicFileDAOImpl dao;

@Transactional
public MusicFile getMusicFile(Integer i){
    return dao.getMusicFile(i);
}
}

@Lob
@Column(name="file")
private byte[] file;
hibernate postgresql
2个回答
2
投票

最基本的是,一个大物体是它自己的东西,与bytea完全不同。如果您要查找字节数组,请使用bytea代替。


0
投票

使用Spring Boot 2+有两种方法:

© www.soinside.com 2019 - 2024. All rights reserved.