草庐IT

test_entity

全部标签

java - 如何仅跳过针对 "compile"和 "install"目标而不是 "test"目标的测试?

我有这样一种情况,我们的单元测试需要很长时间才能为我们的业务域项目执行,因为它将数据库设置为已知状态,然后继续执行每个步骤。我知道这可以通过命令行上的“-Dmaven.test.skip=true”来完成,但希望仅在项目的NetBeans中配置它,如果有人可以阐明如何在IDE中进行配置,则全局是可以接受的。如何将maven2配置为仅在调用“测试”目标时执行测试?即使调用“测试”目标(fromthemavendocos),使用以下命令也会禁用测试。org.apache.maven.pluginsmaven-surefire-plugin2.6true 最佳答案

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

java - 如何让 Jersey Test/Client 不填写默认的 Accept header ?

我正在尝试以特定方式处理没有Acceptheader的请求,但无论我做什么,Jersey似乎都一心想填写一个,所以它看起来总是请求有一个Acceptheader,即使它没有。importorg.glassfish.jersey.server.ResourceConfig;importorg.glassfish.jersey.test.JerseyTest;importorg.junit.Test;importjavax.ws.rs.GET;importjavax.ws.rs.Path;importjavax.ws.rs.core.Application;importjavax.ws.r

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 - 在类 Test 中实例化类 Test 的成员是递归吗?

这是递归吗?publicclassTest{Testtest=newTest();publicstaticvoidmain(String[]args){newTest();}}关于instanceinitalizer的版本呢??publicclassTest{{Testtest=newTest();}publicstaticvoidmain(String[]args){newTest();}}我在问,因为我更新了myoldanswer,它展示了如何在没有递归的情况下生成StackOverflowError,但现在我不能100%确定上面的代码是否是递归的。 最