草庐IT

USER_ENTITY

全部标签

java - 如果 Address 嵌套在 User 中,为什么我必须保留这两个对象?

我试图更好地熟悉JPA,因此我创建了一个非常简单的项目。我有一个用户类和一个地址类。似乎我必须坚持两者,即使我将地址添加到我的用户类?用户:importjavax.persistence.*;importjava.util.HashSet;importjava.util.List;importjava.util.Set;@Entity@Table(name="usr")//@Tableisoptional,but"user"isakeywordinmanySQLvariants@NamedQuery(name="User.findByName",query="selectufromUs

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 - 为什么 user.dir 系统属性在 Java 中有效?

我读过的几乎每篇文章都告诉我,在Java中不能有chdir。thisquestion的公认答案说你不能用Java做到这一点。但是,这是我尝试过的一些东西:geo@codebox:~$java-versionjavaversion"1.6.0_14"Java(TM)SERuntimeEnvironment(build1.6.0_14-b08)JavaHotSpot(TM)ClientVM(build14.0-b16,mixedmode,sharing)Here'satestclassI'musing:importjava.io.*;publicclassCh{publicstaticvo

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

java - 如何为@Entity设置表空间?

我正在使用hibernate自动创建一些postgres数据库表。现在我想将其中一张table移动到不同的位置(硬盘驱动器)。这是使用表空间完成的。问题:如何为@Entity定义表空间?这可能吗? 最佳答案 从4.3.9版本开始,Hibernate中不再支持tablespaces,这让您有两个选择:您可以自定义hbmddl生成以将tablespace包含为previouslysuggested.你放开hbmddl并简单地使用你自己的incrementaldatabaseschema一代。FlywayDB既简单又强大,您可以最大程度地

java - JPA事务回滚重试和恢复: merging entity with auto-incremented @Version

我想在交易失败后恢复。现在,当然,在任何回滚之后,所有实体都会分离并且实体管理器会关闭。但是,UI仍然保留分离的实体。显然我们不能就这样丢弃用户的更改,所以我们想让他们重试(修复突出显示的验证错误,然后再次单击按钮)。在JavaPersistenceWikiBook之后,OnemethodoferrorhandlingistocallmergeforeachmanagedobjectafterthecommitfailsintoanewEntityManager,thentrytocommitthenewEntityManager.Oneissuemaybethatanyidsthat

java - 将客户端 REQUEST_ENTITY_PROCESSING 设置为 CHUNKED 我丢失了文件

我有一个在Jetty上运行的REST网络服务。我想编写一个Java客户端,它使用相同的Web连接将大量文档分块到该其余服务。我能够在这里建立一个基于迭代器的流方法:SendingastreamofdocumentstoaJersey@POSTendpoint这不起作用,除非您设置clientConfig.property(ClientProperties.REQUEST_ENTITY_PROCESSING,RequestEntityProcessing.CHUNKED);,因为Content-length未知。虽然有些工作,但分块传输似乎丢失了一些文档。例如:num_docs50000

java - 同一个类上注解Entity和Component是不是错了

将来自spring@Component和JPA@Entity的注释放在同一个类上是错误的想法吗?为什么需要它是在JSF页面上使用这个类,它还描述了表结构。原因是为了避免将实体对象映射到将成为表示层的某个值对象。这是一些反模式吗?你有更好的解决方案吗? 最佳答案 Isitwrongideatoputannotationfromspring@ComponentandJPA@Entityonthesameclass.这是Controller和模型的紧耦合。WhyItisneededistousethisclassonJSFpageanda