当然,每个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;
最基本的是,一个大物体是它自己的东西,与bytea完全不同。如果您要查找字节数组,请使用bytea代替。
使用Spring Boot 2+有两种方法: