我遇到了一个"映射X和Y彼此不一致"教条错误,所以 我首先在SE上浏览一些类似的问题:
This question成就了
错误地多次使用相同的mappedby
键 - 不是我的情况。
This question 错误的是通过ID而不是对象引用将实体彼此连接起来。我没有 指定似乎不是我的问题的类型(见下文)。
This question使用yml文件指定映射 - 不是我的情况。
This question
错误地命名mappedBy
和inversedBy
键 - 就我所见而言,不是我的情况。
This question 通过在注释中使用FQCN来解决,我做了 - 见下文。
完整的错误消息:
$ php bin/console doctrine:schema:validate
[Mapping] FAIL - The entity-class 'AppBundle\Entity\Comment' mapping is invalid:
* The mappings AppBundle\Entity\Comment#cmtauthor and AppBundle\Entity\User#comments are inconsistent with each other.
[Mapping] FAIL - The entity-class 'AppBundle\Entity\User' mapping is invalid:
* The association AppBundle\Entity\User#comments refers to the owning side field AppBundle\Entity\Comment#cmtauthour which does not exist.
[Database] FAIL - The database schema is not in sync with the current mapping file.
$
以下是我课程的内容(为简单起见,我不包括 由Doctrine自动生成的getters / setters / constructors:
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validation\Constraints as Assert;
/**
* @ORM\Entity
* @ORM\Table(name="nruser")
*
**/
class User
{
/**
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\OneToMany(
* targetEntity="AppBundle\Entity\Comment",
* mappedBy="cmtauthour",
* orphanRemoval=true
* )
*
*/
private $comments;
/**
* @ORM\OneToMany(
* targetEntity="AppBundle\Entity\Post",
* mappedBy="postauthor",
* orphanRemoval=true
* )
*
*/
private $posts;
}
/**
* @ORM\Entity
* @ORM\Table(name="post")
*
**/
class Post
{
/**
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\OneToMany(
* targetEntity="AppBundle\Entity\Comment",
* mappedBy="post",
* orphanRemoval=true
* )
*
*/
private $comments;
/**
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", inversedBy="posts")
* @ORM\JoinColumn(nullable=false)
*/
private $postauthor;
}
/**
* @ORM\Entity
* @ORM\Table(name="comment")
*
**/
class Comment
{
/**
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Post", inversedBy="comments")
* @ORM\JoinColumn(nullable=false)
*/
private $post;
/**
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", inversedBy="comments")
* @ORM\JoinColumn(nullable=false)
*/
private $cmtauthor;
}
任何帮助表示感谢。
答案 0 :(得分:2)
检查package com.companyname.mobile.container.projectDetailsContainer.top.center.progCircle;
import java.io.IOException;
import com.codename1.ui.Component;
import com.codename1.ui.Container;
import com.codename1.ui.Graphics;
import com.codename1.ui.Image;
import com.codename1.ui.Label;
import com.codename1.ui.layouts.FlowLayout;
import com.codename1.ui.layouts.LayeredLayout;
import com.codename1.ui.util.Resources;
import com.codename1.ui.Graphics;
import com.codename1.ui.geom.Rectangle;
/**
* This class partly draws and partly displays the round progress circle
* one can see in the north of ProjectDetailsForm.
*
* It uses a LayeredLayout to paint the progress as a circle in the background
* while concealing the unnecessary part of it with a picture. On the GlassPane
* layer, there is a label showing the progress in percent
*
* {@http://stackoverflow.com/questions/35841377/how-to-make-a-round-progress-bar-in-codename-one}
*
*/
public class ProgressCircle extends Container {
/* attributes */
private Label percent;
private LayeredLayout layout;
/************************/
/* constants */
public static final String ROUND_PROG_BAR = "roundprogbar.png";
/************************/
/**
* Constructor for the round progress bar.
* The parameter given is the color it will be drawn in.
*
* @param statusColor color the progress will be drawn in
*/
public ProgressCircle (int statusColor) {
layout = new LayeredLayout();
this.setLayout(layout);
try {
Resources s = Resources.open("/theme.res");
Image progressOverlayImage = s.getImage(ROUND_PROG_BAR);
int currentProgress360 = 100;
percent = new Label (String.valueOf((int) (((double)currentProgress360 /360)*100))+ "%");
percent.getUnselectedStyle().setFgColor(0x000000);
percent.getUnselectedStyle().setAlignment(Component.CENTER);
this.add(new Label (progressOverlayImage.scaled((int)(progressOverlayImage.getWidth()*0.65), (int)(progressOverlayImage.getHeight()*0.65)), "Container")).
add(FlowLayout.encloseCenterMiddle(percent));
this.getUnselectedStyle().setBgPainter((Graphics g, Rectangle rect) -> {
g.setColor(statusColor);
g.fillArc(this.getX(), this.getY(),(int)(progressOverlayImage.getWidth()*0.65), (int)(progressOverlayImage.getHeight()*0.65), 0, currentProgress360);
});
} catch (IOException e) {
e.printStackTrace();
}
}
}
转储架构更新查询的原因:
schema is not in sync