无法添加<entity>,因为它已映射到<package>实体类,并且该实体不在当前项目源中</package> </entity>

时间:2014-10-11 16:56:27

标签: netbeans jdbc glassfish database-connection connection-pooling

我认为Netbeans中的缓存可能存在问题,导致创建新Entity Classes from Database...时出现问题。

Netbeans错误:

clients cannot be added because it is already mapped to the net.bounceme.dur.jpa.Client entity class and the entity is not in current project source.

cannot be added

请注意,这是使用资源jdbc/ejb

IDE生成的persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  <persistence-unit name="A-ejbPU" transaction-type="JTA">
    <jta-data-source>jdbc/ejb</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
      <property name="javax.persistence.schema-generation.database.action" value="create"/>
    </properties>
  </persistence-unit>
</persistence>

以及由IDE生成的相关glassfish-resources.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
    <jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="mysql_legacy_jdbcPool" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
        <property name="serverName" value="localhost"/>
        <property name="portNumber" value="3306"/>
        <property name="databaseName" value="legacy"/>
        <property name="User" value="jdbc"/>
        <property name="Password" value="password"/>
        <property name="URL" value="jdbc:mysql://localhost:3306/legacy?zeroDateTimeBehavior=convertToNull"/>
        <property name="driverClass" value="com.mysql.jdbc.Driver"/>
    </jdbc-connection-pool>
    <jdbc-resource enabled="true" jndi-name="jdbc/ejb" object-type="user" pool-name="mysql_legacy_jdbcPool"/>
</resources>

glassfish server, might not be directly related上的其他资源:

thufir@dur:~/NetBeansProjects$ 
thufir@dur:~/NetBeansProjects$ /home/thufir/glassfish-4.1/glassfish/bin/asadmin
Use "exit" to exit and "help" for online help.
asadmin> 
asadmin> list-jdbc-connection-pools
CLI031: Warning: Option "target" is obsolete and will be ignored.
CLI031: Warning: Option "target" is obsolete and will be ignored.
__TimerPool
DerbyPool
SamplePool
connectionPool
legacy_on_glassfish
Command list-jdbc-connection-pools executed successfully.
asadmin> 
asadmin> ping-connection-pool legacy_on_glassfish
Command ping-connection-pool executed successfully.
asadmin> 
asadmin> list-jdbc-resources
jdbc/sample
jdbc/__TimerPool
jdbc/__default
jdbc/local
jdbc/legacy_resource
Command list-jdbc-resources executed successfully.
asadmin> 
asadmin> exit
Command multimode executed successfully.
thufir@dur:~/NetBeansProjects$ 

虽然我认为glassfish服务器上的那些资源是unrelated,但可能会有一些相互作用。

我查了一下:

thufir@dur:~$ 
thufir@dur:~$ ls /home/thufir/.netbeans
8.0.1
thufir@dur:~$ 
thufir@dur:~$ ls /home/thufir/netbeans-8.0.1/
apisupport    etc      java                      nb            README.html            websvccommon
bin           extide   javafx                    netbeans.css  THIRDPARTYLICENSE.txt
CREDITS.html  harness  LICENSE.txt               platform      uninstall.sh
enterprise    ide      moduleCluster.properties  profiler      webcommon
thufir@dur:~$ 

另见:

X cannot be added because it is already mapped to the entities. X entity class and the entity is not in current project source

http://pietervogelaar.nl/ubuntu-11-04-netbeans-7-clear-cache

或许我只是没有看到缓存,假设这是问题?

0 个答案:

没有答案