jpa - 无法在 Eclipse 中使用外键从 table 生成实体(sql 服务器)
jpa - can not generate entities from table in eclipse with foreign key (sql server)
我无法在 Eclipse 中使用外键从 table 生成实体。我正在使用 sql 服务器。这是我的 tables 的架构:
Pointage.Id 和 Pause.IdPointage 之间有一个外键。当我尝试生成两个 table 时生成失败。产生点数但不产生暂停。在生成 Pause Table 的最后一个屏幕中,看起来是空的(没有列)。当我只导入 Pause 时它也会失败,但当我删除外键时它运行良好。
我可以在工作区日志中看到错误:
org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getImportStatements' in class org.eclipse.jpt.jpa.gen.internal.ORMGenTable threw exception java.lang.IllegalStateException: Pause.FK_Pause_Pointage - mismatched sizes: 0 vs. 1 @ main.java.vm[7,9]
at org.apache.velocity.runtime.parser.node.ASTIdentifier.execute(ASTIdentifier.java:205)
at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:203)
at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:294)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318)
at org.apache.velocity.Template.merge(Template.java:254)
at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:508)
at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:473)
at org.eclipse.jpt.jpa.gen.internal.PackageGenerator.generateJavaFile(PackageGenerator.java:333)
at org.eclipse.jpt.jpa.gen.internal.PackageGenerator.generateClass(PackageGenerator.java:310)
at org.eclipse.jpt.jpa.gen.internal.PackageGenerator.generateInternal(PackageGenerator.java:132)
at org.eclipse.jpt.jpa.gen.internal.PackageGenerator.doGenerate(PackageGenerator.java:106)
at org.eclipse.jpt.jpa.gen.internal.PackageGenerator.generate(PackageGenerator.java:82)
at org.eclipse.jpt.jpa.ui.internal.wizards.gen.GenerateEntitiesFromSchemaWizard$GenerateEntitiesJob.runInWorkspace(GenerateEntitiesFromSchemaWizard.java:285)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:39)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.lang.IllegalStateException: Pause.FK_Pause_Pointage - mismatched sizes: 0 vs. 1
at org.eclipse.jpt.jpa.db.internal.DTPForeignKeyWrapper.buildColumnPairArray(DTPForeignKeyWrapper.java:116)
at org.eclipse.jpt.jpa.db.internal.DTPForeignKeyWrapper.getColumnPairArray(DTPForeignKeyWrapper.java:106)
at org.eclipse.jpt.jpa.db.internal.DTPForeignKeyWrapper.getLocalColumnPairs(DTPForeignKeyWrapper.java:101)
at org.eclipse.jpt.jpa.db.internal.DTPForeignKeyWrapper.getBaseColumns(DTPForeignKeyWrapper.java:146)
at org.eclipse.jpt.jpa.db.internal.DTPForeignKeyWrapper.baseColumnsContains(DTPForeignKeyWrapper.java:150)
at org.eclipse.jpt.jpa.db.internal.DTPTableWrapper.foreignKeyBaseColumnsContains(DTPTableWrapper.java:216)
at org.eclipse.jpt.jpa.db.internal.DTPColumnWrapper.isPartOfForeignKey(DTPColumnWrapper.java:58)
at org.eclipse.jpt.jpa.gen.internal.ORMGenColumn.isForeignKey(ORMGenColumn.java:266)
at org.eclipse.jpt.jpa.gen.internal.ORMGenTable.buildColumnTypesMap(ORMGenTable.java:206)
at org.eclipse.jpt.jpa.gen.internal.ORMGenTable.getImportStatements(ORMGenTable.java:138)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.velocity.runtime.parser.node.PropertyExecutor.execute(PropertyExecutor.java:137)
at org.apache.velocity.util.introspection.UberspectImpl$VelGetterImpl.invoke(UberspectImpl.java:350)
at org.apache.velocity.runtime.parser.node.ASTIdentifier.execute(ASTIdentifier.java:180)
... 14 more
这是 Eclipse Dali (https://bugs.eclipse.org/bugs/show_bug.cgi?id=281991), which is the result of a bug in Eclipse DTP (https://bugs.eclipse.org/bugs/show_bug.cgi?id=282206) 中的错误。在 inactivity 几年接近完成之后,DTP 最近有了一些发展 activity;因此,也许如果您对后一个错误投票,它可能会得到修复。 :-)
这是数据库的权限问题。赋予用户更多权限后,我没有在eclipse中重启数据库连接。完成后,一切正常。
我无法在 Eclipse 中使用外键从 table 生成实体。我正在使用 sql 服务器。这是我的 tables 的架构:
Pointage.Id 和 Pause.IdPointage 之间有一个外键。当我尝试生成两个 table 时生成失败。产生点数但不产生暂停。在生成 Pause Table 的最后一个屏幕中,看起来是空的(没有列)。当我只导入 Pause 时它也会失败,但当我删除外键时它运行良好。
我可以在工作区日志中看到错误:
org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getImportStatements' in class org.eclipse.jpt.jpa.gen.internal.ORMGenTable threw exception java.lang.IllegalStateException: Pause.FK_Pause_Pointage - mismatched sizes: 0 vs. 1 @ main.java.vm[7,9]
at org.apache.velocity.runtime.parser.node.ASTIdentifier.execute(ASTIdentifier.java:205)
at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:203)
at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:294)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318)
at org.apache.velocity.Template.merge(Template.java:254)
at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:508)
at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:473)
at org.eclipse.jpt.jpa.gen.internal.PackageGenerator.generateJavaFile(PackageGenerator.java:333)
at org.eclipse.jpt.jpa.gen.internal.PackageGenerator.generateClass(PackageGenerator.java:310)
at org.eclipse.jpt.jpa.gen.internal.PackageGenerator.generateInternal(PackageGenerator.java:132)
at org.eclipse.jpt.jpa.gen.internal.PackageGenerator.doGenerate(PackageGenerator.java:106)
at org.eclipse.jpt.jpa.gen.internal.PackageGenerator.generate(PackageGenerator.java:82)
at org.eclipse.jpt.jpa.ui.internal.wizards.gen.GenerateEntitiesFromSchemaWizard$GenerateEntitiesJob.runInWorkspace(GenerateEntitiesFromSchemaWizard.java:285)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:39)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.lang.IllegalStateException: Pause.FK_Pause_Pointage - mismatched sizes: 0 vs. 1
at org.eclipse.jpt.jpa.db.internal.DTPForeignKeyWrapper.buildColumnPairArray(DTPForeignKeyWrapper.java:116)
at org.eclipse.jpt.jpa.db.internal.DTPForeignKeyWrapper.getColumnPairArray(DTPForeignKeyWrapper.java:106)
at org.eclipse.jpt.jpa.db.internal.DTPForeignKeyWrapper.getLocalColumnPairs(DTPForeignKeyWrapper.java:101)
at org.eclipse.jpt.jpa.db.internal.DTPForeignKeyWrapper.getBaseColumns(DTPForeignKeyWrapper.java:146)
at org.eclipse.jpt.jpa.db.internal.DTPForeignKeyWrapper.baseColumnsContains(DTPForeignKeyWrapper.java:150)
at org.eclipse.jpt.jpa.db.internal.DTPTableWrapper.foreignKeyBaseColumnsContains(DTPTableWrapper.java:216)
at org.eclipse.jpt.jpa.db.internal.DTPColumnWrapper.isPartOfForeignKey(DTPColumnWrapper.java:58)
at org.eclipse.jpt.jpa.gen.internal.ORMGenColumn.isForeignKey(ORMGenColumn.java:266)
at org.eclipse.jpt.jpa.gen.internal.ORMGenTable.buildColumnTypesMap(ORMGenTable.java:206)
at org.eclipse.jpt.jpa.gen.internal.ORMGenTable.getImportStatements(ORMGenTable.java:138)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.velocity.runtime.parser.node.PropertyExecutor.execute(PropertyExecutor.java:137)
at org.apache.velocity.util.introspection.UberspectImpl$VelGetterImpl.invoke(UberspectImpl.java:350)
at org.apache.velocity.runtime.parser.node.ASTIdentifier.execute(ASTIdentifier.java:180)
... 14 more
这是 Eclipse Dali (https://bugs.eclipse.org/bugs/show_bug.cgi?id=281991), which is the result of a bug in Eclipse DTP (https://bugs.eclipse.org/bugs/show_bug.cgi?id=282206) 中的错误。在 inactivity 几年接近完成之后,DTP 最近有了一些发展 activity;因此,也许如果您对后一个错误投票,它可能会得到修复。 :-)
这是数据库的权限问题。赋予用户更多权限后,我没有在eclipse中重启数据库连接。完成后,一切正常。