标签: mappingexception

映射实体错误的另一个重复列

尽管其他所有人都发布了,但我无法在MacOSX,NetBeans 7.2上找到GlassFish的错误解决方案.

Here the error :
SEVERE: Exception while invoking class org.glassfish.persistence.jpa.JPADeployer
prepare method
SEVERE: Exception while preparing the app
SEVERE: [PersistenceUnit: supmarket] Unable to build EntityManagerFactory

...

Caused by: org.hibernate.MappingException: Repeated column in mapping for entity:
com.supmarket.entity.Sale column: customerId
(should be mapped with insert="false" update="false")
Run Code Online (Sandbox Code Playgroud)

这里的代码:

Sale.java

@Entity
public class Sale {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(nullable=false)
    private Long idFromAgency;

    private float amountSold;

    private String agency;

    @Temporal(javax.persistence.TemporalType.DATE)
    private Date createdate;

    @Column(nullable=false)
    private Long productId;

    @Column(nullable=false)
    private …
Run Code Online (Sandbox Code Playgroud)

hibernate java-ee mappingexception

95
推荐指数
4
解决办法
17万
查看次数

Hibernate:未映射的类关联异常

我知道这应该是一个非常基本的问题需要修复,但1)我对Hibernate相对较新,2)我发现的修复程序(似乎)不适用于此处.

以下是我得到的例外情况:

org.hibernate.MappingException: An association from the table POSTS refers to
 an unmapped class: com.beans.User at 
 org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1285)

当Hibernate尝试自行配置时会发生这种情况.

我正在使用的对象是用户,帖子(抽象超类),状态和注释(Post的具体子类).每个都是来自两个表之一的bean:USERS和POSTS.用户对象很漂亮:许多描述用户的平淡字段.除了类似的无聊字段,状态和评论都有所有者(发布它的用户).状态与注释的区别在于,状态可以附加一个注释列表但没有父项,而注释没有子项,但有一个父项(是的,这基本上是Facebook).

从我所读到的,问题似乎是多对一的映射,但我似乎无法找到任何错误.这是我正在使用的三个配置文件.

hibernate.cfg.xml中:

<hibernate-configuration>
    <session-factory>
        ...
        <!-- mapped persistence classes -->
        <mapping resource="User.hbm.xml" />
        <mapping resource="Post.hbm.xml" />
    </session-factory>
</hibernate-configuration>

User.hbm.xml:

<hibernate-mapping>
    <class name="com.beans.User" entity-name="User" table="USERS" proxy="User">
        <id name="uid" type="java.lang.Integer">
            <column name="uid" />
            <generator class="assigned" />
        </id>
        ...
    </class>
</hibernate-mapping>

Post.hbm.xml:

<hibernate-mapping>
    <class name="com.beans.Post" entity-name="Post" table="POSTS" proxy="Post" abstract="true">
        <id name="pid" type="java.lang.Integer">
            <column name="pid" />
            <generator class="assigned" />
        </id>            
        <discriminator column="type" />
        <one-to-one name="parent" …
Run Code Online (Sandbox Code Playgroud)

hibernate exception hibernate-mapping mappingexception

8
推荐指数
1
解决办法
3万
查看次数

Symfony2/Doctrine2无效的映射文件在尝试生成实体时出现异常

我有一个非常简单的数据库,我试图导入,并从中创建实体.Doctrine(Symfony)能够从数据库生成YML映射文件.但是,当我临时尝试生成实体时,我收到以下错误:

[Doctrine\Common\Persistence\Mapping\MappingException]
Invalid mapping file 'SandboxBundle.Entity.Product.orm.yml' for class
'SandboxBundle\Entity\Product'.
Run Code Online (Sandbox Code Playgroud)

yml文件对我来说很好,因为我们期望它是由Doctrine生成的.只是为了确定,我检查了一个在线yml验证器,它说没关系.我用来尝试生成实体的命令是:

app/console generate:doctrine:entities sandbox
Run Code Online (Sandbox Code Playgroud)

.yml文件如下.请原谅这里粘贴文件导致的任何yml间距错误.正如我所说,yml文件是由doctrine生成的,并且确实通过了在线验证.

Product:
  type: entity
  table: product
    indexes:
      category_id:
          columns:
              - category_id
  id:
      id:
          type: integer
          nullable: false
          unsigned: false
          comment: ''
          id: true
          generator:
              strategy: IDENTITY
  fields:
      productname:
          type: string
          nullable: true
          length: 10
          fixed: false
          comment: ''
      categoryId:
          type: integer
          nullable: true
          unsigned: false
          comment: ''
          column: category_id
 lifecycleCallbacks: {  }
Run Code Online (Sandbox Code Playgroud)

为了完整起见,这里是Category yml文件.错误发生在产品上,但我认为这是因为产品首先得到处理.

Category:
   type: entity
   table: category
       id:
          id:
              type: integer
              nullable: false
              unsigned: false …
Run Code Online (Sandbox Code Playgroud)

php mappingexception symfony doctrine-orm

6
推荐指数
1
解决办法
8702
查看次数

org.hibernate.MappingException:未知实体:pack1.Persoana

我收到此错误,我不知道我的hbm.xml文件有什么问题.我使用Eclipse Mars和Hibernate 5.0.2.

错误:

Nov 15, 2015 11:49:19 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {5.0.2.Final}
Nov 15, 2015 11:49:19 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Nov 15, 2015 11:49:19 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Nov 15, 2015 11:49:19 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {5.0.0.Final}
Nov 15, 2015 11:49:20 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!)
Nov 15, 2015 11:49:20 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator …
Run Code Online (Sandbox Code Playgroud)

hibernate hibernate.cfg.xml mappingexception hbmxml

5
推荐指数
1
解决办法
907
查看次数

AutoMapper.AutoMapperMappingException

我知道关于这个主题已经被问到了很多问题,但他们都没有为我的问题提供答案。这就是为什么我要创建一个新问题。

我已经在 google 和 here 上寻找答案,并找到了一些改进了我的 AutoMapper 设置的方法。(即只创建一次映射)

我的问题是我有时会遇到异常,有时不会。我完全不知道如何解决它。我已经搜索了一整天,但找不到任何东西。

当我运行 Mapper.AssertConfigurationIsValid(); 它成功。

我尝试添加以下内容:

Mapper.Configuration.AllowNullDestinationValues = true;
Mapper.AllowNullDestinationValues = true;  
Run Code Online (Sandbox Code Playgroud)

而且我仍然收到错误:s

我的设置如下:

在我的 global.asax 文件中,我调用 AutoMapperSetup.SetupAutoMapper()。

protected void Application_Start(object sender, EventArgs e)
    {
        ...
        AutoMapperSetup.SetupAutoMapper();
    }
Run Code Online (Sandbox Code Playgroud)

AutoMapperSetup 类描述如下:(我知道我的静态构造函数正在执行。如果我放置断点,它就会被命中。所以代码确实被执行了)

public static class AutoMapperSetup
{

static AutoMapperSetup()
    {
        #region GetPlanning
        Mapper.CreateMap<GetPlanningResult_v3, FWSGetPlanningResult>()
            .ForSourceMember(x => x.ItemSelection, y => y.Ignore())
            .ForAllMembers(op => op.Condition(x => !x.IsSourceValueNull));
        Mapper.CreateMap<ExecutionResult, FWSExecutionResult>()
            .ForAllMembers(op => op.Condition(x => !x.IsSourceValueNull));
        Mapper.CreateMap<ExecutionResult.Error, FWSExecutionResult.FWSError>()
            .ForAllMembers(op => op.Condition(x => !x.IsSourceValueNull));
        Mapper.CreateMap<ExecutionResult.Warning, FWSExecutionResult.FWSWarning>()
            .ForAllMembers(op => op.Condition(x => …
Run Code Online (Sandbox Code Playgroud)

c# automapper mappingexception

5
推荐指数
1
解决办法
1万
查看次数

如何使SoapUI json请求与德语变音符号一起使用?

我们将SoapUI用于团队项目中的许多接口.我们遇到了德国特殊标志的问题,称为变形金刚.当发送带有Json主体和德国变音符号的POST请求时,我们得到了com.fasterxml.jackson.databind.JsonMappingException.它无法解析com.fasterxml.jackson.databind.ObjectMapper.

SoapUI Json请求

但是当使用POSTMAN发送相同的请求时,它就像一个魅力. 邮差Json请求

我们使用@Consumes({MediaType.APPLICATION_JSON + "; charset=utf-8"})注释和Content-Type: application/json; charset=utf-8标题.但仍然没有效果.有没有人遇到这样的问题或知道如何解决它?我们无法更改测试工具.

rest json soapui character-encoding mappingexception

3
推荐指数
1
解决办法
4082
查看次数

Hibernate"无法确定...的类型"ManyToOne OneToMany映射

我担心这是一个非常普遍的问题,但无论如何我无法解决它.-我想组织活动和地点.在一个地方可以进行几项活动.

归结为以下几点:

地点:

@OneToMany(fetch = FetchType.LAZY, mappedBy="location")
private List<Event> events = new ArrayList<Event>();
Run Code Online (Sandbox Code Playgroud)

事件:

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "location_id")
private Location location;
Run Code Online (Sandbox Code Playgroud)

我总是得到这个错误:

初始SessionFactory创建failed.org.hibernate.MappingException:无法确定:com.mycompany.domain.Location的类型,在表:Event,对于列:[org.hibernate.mapping.Column(location)]

老实说,我没有提前看到错误....

整个代码:

事件:

package com.mycompany.domain;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.*;

@Entity
@Table
public class Event {
@Id
@GeneratedValue
private Long id;

private String name;

private Date date;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "location_id")
private Location location;

@OneToMany(fetch = FetchType.LAZY, mappedBy = "event")
private List<UserAttendsEvent> userAttendsEvents = new ArrayList<UserAttendsEvent>() ;

@OneToMany(fetch = FetchType.LAZY, …
Run Code Online (Sandbox Code Playgroud)

hibernate one-to-many many-to-one mappingexception

3
推荐指数
1
解决办法
3036
查看次数

映射异常:类不存在Symfony2部署

我在localhost上有一个工作项目,但是当我部署项目时,我收到了这个错误,我不知道是什么导致了这种情况发生.

 MappingException: Class 'PremiumPharma\SystemBundle\Entity\User' does not exist
Run Code Online (Sandbox Code Playgroud)

这是堆栈跟踪

in /home/sy2/public_html/temp/symfony/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php line 96
at MappingException::nonExistingClass('PremiumPharma\SystemBundle\Entity\User') in /home/sy2/public_html/temp/symfony/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php line 43
at RuntimeReflectionService->getParentClasses('PremiumPharma\SystemBundle\Entity\User') in /home/sy2/public_html/temp/symfony/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php line 267
Run Code Online (Sandbox Code Playgroud)

编辑1 我确实注意到探查器中有一些错误,因为它说5个无效实体,并且有一些映射错误,我修复了它们.重新上传后,我仍然有同样的问题.我也尝试清空缓存,但仍然收到相同的错误.

编辑2

这是我的appKernal

<?php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            new Symfony\Bundle\TwigBundle\TwigBundle(),
            new Symfony\Bundle\MonologBundle\MonologBundle(),
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Symfony\Bundle\AsseticBundle\AsseticBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new PremiumPharma\SystemBundle\PremiumPharmaSystemBundle(),
            new FOS\UserBundle\FOSUserBundle(),
        );

        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            $bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
            $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
            $bundles[] …
Run Code Online (Sandbox Code Playgroud)

deployment doctrine mappingexception symfony

2
推荐指数
1
解决办法
2万
查看次数

使用可空类型时会发生NHibernate.MappingException

我使用nhibernate访问我的数据库,andromda生成我的映射文件.一切正常,只要我没有使用可空数据类型.我想要的是拥有一个类型为Nullables.NHibernate.NullableInt32Type的实体.我的数据库与"int NULL"(SQL Server)类型的列具有对应关系.相应的类也具有正确的数据类型(int?).但是当我尝试获取数据库的值时,我得到一个NHibernate.MappingException:

NHibernate.MappingException:为类型Namespace.SummaryAttribute指定的映射信息无效,请检查映射文件中是否存在属性类型不匹配----> System.InvalidCastException:Die angegebene Umwandlungistungültig.

<?xml version="1.0" encoding="UTF-8"?>
<hibernate-mapping
    xmlns="urn:nhibernate-mapping-2.2"
    default-cascade="none">

    <class
        name="Namespace.SummaryAttribute, Core"
        table="SUMMARY_ATTRIBUTE"
        dynamic-insert="false"
        dynamic-update="false"
        lazy="true">

        <id name="Id" type="Int64" unsaved-value="0">
            <column name="ID" sql-type="NUMERIC(19,0)"/>
            <generator class="native">
            </generator>
        </id>

        <property name="ShortName" type="String">
            <column name="SHORT_NAME" not-null="true" unique="false" sql-type="VARCHAR(255)"/>
        </property>

        <property name="LongName" type="String">
            <column name="LONG_NAME" not-null="true" unique="false" sql-type="VARCHAR(255)"/>
        </property>

        <property name="Description" type="String">
            <column name="DESCRIPTION" not-null="true" unique="false" sql-type="VARCHAR(255)"/>
        </property>

        <property name="IsVisible" type="Boolean">
            <column name="IS_VISIBLE" not-null="true" unique="false" sql-type="BIT"/>
        </property>

        <property name="DecimalPlaces" type="Nullables.NHibernate.NullableInt32Type, Nullables.NHibernate">
            <column name="DECIMAL_PLACES" not-null="false" unique="false" sql-type="INT"/>
        </property>
    </class>
</hibernate-mapping>
Run Code Online (Sandbox Code Playgroud)

没有属性"DecimalPlaces"一切正常.即使我将属性更改为简单数据类型int. …

nhibernate nullable mappingexception andromda

0
推荐指数
1
解决办法
2089
查看次数