数据库更改后JPA和MySQL不同步

时间:2015-03-09 07:57:20

标签: mysql eclipse jpa glassfish eclipselink

我使用JPA-eclipseLink 2.5.0,Glassfish 4.1,MySQL,Eclipse Luna 4.4.0,Java8

我已经创建了mydatabase并创建了实体

一切正常

然后我更改了一些表,并在数据库中更改了一些属性,然后问题发生了

当我开始运行我的应用程序时,它会给我这个错误

cannot Deploy monsterpuzzle deploy is failing=Error occurred during deployment: Exception while deploying the app [monsterpuzzle] : Exception [EclipseLink-28019] (Eclipse Persistence Services -
2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.EntityManagerSetupException Exception Description: Deployment of PersistenceUnit [MonsterPuzzle] failed. Close all factories for this PersistenceUnit. Internal Exception: Exception [EclipseLink-0] (Eclipse Persistence Services -
2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.IntegrityException Descriptor Exceptions: 

--------------------------------------------------------- Exception [EclipseLink-48] (Eclipse Persistence Services - 2.5.2.v20140319-
9ad6abd): org.eclipse.persistence.exceptions.DescriptorException Exception Description: Multiple writable mappings exist for the field [PRICE.ITEMID].  Only one may be defined as writable, all others must be specified read-only. Mapping: org.eclipse.persistence.mappings.OneToOneMapping[item] Descriptor: RelationalDescriptor(model.Price --> [DatabaseTable(PRICE)])

根据错误,我认为错误是表'PRICE'的映射关系,

但我已经删除了表'PRICE'和实体,所以我认为我的应用程序不知道我已经更改了一些数据..

我已经多次检查我的实体,我认为它没有问题。

我认为问题是..我的项目仍然使用旧连接,我需要刷新它

我已经清理,构建,重新发布我的项目,刷新连接池,创建新的连接池,重启glassfish,重启我的电脑。但它仍然给我同样的错误

任何帮助?

原谅我的英语谢谢

编辑2:

持久性配置(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="MonsterPuzzle" transaction-type="JTA">
        <jta-data-source>GameMonsterPuzzle</jta-data-source>
    </persistence-unit>
</persistence>

获取实体经理我使用此代码

@Stateless
@LocalBean
public class DaoBoxBattle extends DaoGeneric<Boxbattle>{

    @PersistenceContext(unitName = "MonsterPuzzle")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        // TODO Auto-generated method stub
        return em;
    }

    public DaoBoxBattle(){
        super(Boxbattle.class);
    }


}

0 个答案:

没有答案