草庐IT

Resolve_target_entities

全部标签

Java JPA : Performant check if Entity is already in DB

使用JPA检查实体是否已在数据库中的最佳方法/最佳实践是什么?我正在编写一个将主机信息添加到数据库的客户端。例如附加的存储lun、hba等...如果我想为主机添加一个Lun,我必须检查该lun是否已经在数据库中。(Lun可以附加到另一个主机上)。我看到了2种可能性:我选择了Lun,检查它是否已经在数据库中尝试插入Lun并检查异常(唯一约束)有人有这方面的经验吗?BR,雷内 最佳答案 entityManager.find(SomeEntity.class,id)Returns:thefoundentityinstanceornulli

java - JAX-RS (Reasteasy) Response.readEntity 抛出 : IllegalStateException: RESTEASY003290: Entity is not backed by an input stream

我对发送JAX-RSPOST调用的方法进行了JUnit测试。为了独立于外部资源,我mock了REST客户端并表示应该返回一个虚拟响应。效果很好,没问题。但是:当调用myResponse.readEntity(String.class)时,我总是得到以下异常:java.lang.IllegalStateException:RESTEASY003290:Entityisnotbackedbyaninputstream这是我失败的代码片段:importcom.google.gson.JsonObject;importcom.google.gson.JsonPrimitive;importja

java.lang.IllegalStateException : Neither BindingResult nor plain target object for bean name 'category' available as request attribute 错误

我在网上查看了几乎所有与此问题相关的答案,但无法找出我的代码中的问题。这是我的JSP页面。当我删除它工作正常。我可以与我的Controller通信。所以问题与这一行有关。@ControllerpublicclassSearchCategory{@AutowiredprivateCategoryServicecategoryService;@RequestMapping(value="/search_category",method=RequestMethod.POST)public@ResponseBodyStringsearchCategoryFromDatabase(@ModelA

java - 嵌入式 id 和 "repeated column in mapping for entity..."异常

我遇到了JPA和Hibernate的问题,但未能解决。所以,这是我的applicationContext.xml:truecreate这是我的性能实体:packagecom.abt.fiifootballmanager.entity;importjava.io.Serializable;importjavax.persistence.*;importjava.math.BigDecimal;importjava.util.List;@Entity@Table(name="PERFORMANCES")@NamedQuery(name="Performance.findAll",query

java - 为什么我得到 "Cannot resolve symbol"?

我以前导入过这个项目,之前没有任何困难。我不确定发生了什么变化。我单击ImportProject并选择getting-started-with-selenium(http://github.com/ddavison/getting-started-with-selenium),这是一个Maven项目和一个旧的Eclipse项目。我单击目录,然后在“选择库”或其他选项中,我选择了Maven。我已经更改了我的构建路径以正确匹配...src/main/java/但是,我得到了"Cannotresolvesymbol'After'"即使在Maven库中,我也清楚地看到它。如果需要任何其他信息,

java - Entity-Bean (JPA) 中的单向关系

如何在EJB3.0Entity-Beans(JPA)中创建单向关系?例如,客户知道订单,但订单没有客户的任何方法。使用(@OneToMany或@OneToOne或@ManyToMany)问候 最佳答案 下面是使用JPA2.0建立单向@OneToMany关系的方法:@EntitypublicclassCustomer{@Id@Column(name="cust_id")privatelongid;...@OneToMany@JoinColumn(name="owner_id",referencedColumnName="cust_id

java - JPA/Spring/Delete Entity,类型不匹配(int/long for id)

我有一个使用的实体@Id@GeneratedValue(strategy=GenerationType.AUTO)privatelongid;我有这个实体的JPA存储库。现在我想删除其中一个,但标准方法是delete(inti),它不起作用,因为我的ID不是整数,而是长整数。那么除了使用int作为我的ID之外,在这里还能做什么?我可以指定一个使用long的自定义删除方法,就像它与findbyXX(XX)一起使用一样吗?编辑:首先:是的,我正在使用DataJPA!我想这样做:jparepository.delete(id);如果id是一个整数:org.hibernate.TypeMism

java - Play Framework : PersistenceException: The type is not a registered entity? (Ebean)

我正在学习适用于Java的PlayFramework2.0教程,但在尝试保存ebean模型(task.save())时遇到此错误。[PersistenceException:Thetype[classmodels.Task]isnotaregisteredentity?Ifyoudon'texplicitlylisttheentityclassestouseEbeanwillsearchforthemintheclasspath.IftheentityisinaJarchecktheebean.search.jarspropertyinebean.propertiesfileorche

java - org.hibernate.HibernateException : Unable to instantiate default tuplizer [org. hibernate.tuple.entity.PojoEntityTuplizer]

我正在尝试学习使用hibernate将一条简单的记录插入MySQL数据库,我正在关注这个article来自Mkyong,我卡在了最后一步,即运行App.Java时。请帮助。提前致谢。pom.xml:4.0.0com.mkyong.commonHibernateExamplejar1.0-SNAPSHOTHibernateExamplehttp://maven.apache.orgjunitjunit3.8.1testmysqlmysql-connector-java5.1.9org.hibernatehibernate-core3.6.3.Finaldom4jdom4j1.6.1com

java - 得到一个 The entity name must immediately follow the '&' in the entity reference error in java, 但我的 xml 文件中没有任何符号

我遇到了错误Theentitynamemustimmediatelyfollowthe'&'intheentityreference.但我的XML文档中没有任何符号!有谁知道为什么会发生这种情况?这是我要解析的XML文档:BestiPadstrategygameshttp://feedproxy.google.com/~r/TheIphoneBlog/~3/198mhX3FVmw/story01.htmShareyourlifewithfriendsinrealtimewithSpinhttp://feedproxy.google.com/~r/TheIphoneBlog/~3/9G8