无法弄清楚如何从我的数据库中检索'blob'类型。无法弄清楚如何在JPA中做。
public interface ActeRepository extends JpaRepository<byte[], String> {
@Query(value = "select doc from t_doc_content", nativeQuery = true)
public List<byte[]> findActeByBordereau(String id);
}
错误:
引起:java.lang.IllegalArgumentException:不是托管类型:class [B. 在org.hibernate.jpa.internal.metamodel.MetamodelImpl.managedType(MetamodelImpl.java:219) 在org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation。(JpaMetamodelEntityInformation.java:68) 在org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:67) 在org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:152) 在org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:99) 在org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:81) 在org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:185) 在org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:251) 在org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:237) at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:92) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ...省略了29个常见帧
有什么想法吗?
答案 0 :(得分:0)
您的界面定义不正确
也许改为
private WebView wv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
wv = (WebView) findViewById(R.id.webview1);
wv.loadUrl("https://www.xxxxx.com.br");
wv.setWebViewClient(new WebViewClient());
WebSettings ws = wv.getSettings();
ws.setJavaScriptEnabled(true);
ws.setSupportZoom(false);
}
主键是否为String,如果是,则上述情况正常,否则将public interface ActeRepository extends JpaRepository< Acte, String> {
更改为它。好久不过?
答案 1 :(得分:0)
这不是JpaRepository
的工作方式,在扩展时,您需要记住它的类型为JpaRepository<T, ID extends Serializable>
,其中T
是您在其中映射为表格的POJO数据库可能使用@Entity
而ID
是您表的主键Long
或Integer
,我怀疑你有一个String作为主键,因为整数更快到指数。我不知道你的其余代码,但是给你一个例子:
@Entity
public class File {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
@Lob
private byte[] bytes;
@ManyToOne
@JoinColumn(name = "user_id")
private User user;
public File() {
}
public File(String name, byte[] bytes, User user) {
this.name = name;
this.bytes = bytes;
this.user = user;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public byte[] getBytes() {
return bytes;
}
public void setBytes(byte[] bytes) {
this.bytes = bytes;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
}
@Repository
public interface FileRepository extends JpaRepository<File, Long>{
List<File> findByName(String name);
}
在获得对象列表后,您将从每个对象获取该字节变量。