我的
mysql数据库和hibernate-tools生成的类都有这个问题,所有这些都运行良好,直到我在涉及4个表的数据库中进行了更改.
这是表格:
–
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=2;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Table `profile`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `fairtime`.`profile` (
`profile_id` INT(11) NOT NULL AUTO_INCREMENT,
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME NULL DEFAULT NULL,
`app_user_id` INT(11) NOT NULL,
`address` VARCHAR(45) NOT NULL,
`phone` VARCHAR(45) NOT NULL,
`city_id` INT(11) NOT NULL,
PRIMARY KEY (`profile_id`),
INDEX `fk_profile_app_user1_idx` (`app_user_id` ASC),
INDEX `fk_profile_city1_idx` (`city_id` ASC),
CONSTRAINT `fk_profile_app_user1`
FOREIGN KEY (`app_user_id`)
REFERENCES `fairtime`.`app_user` (`app_user_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_profile_city1`
FOREIGN KEY (`city_id`)
REFERENCES `fairtime`.`city` (`city_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `profile_option`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `fairtime`.`profile_option` (
`profile_option_id` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`hidden_for_user` TINYINT(1) NOT NULL DEFAULT '0' COMMENT 'Specify if a target option is readable by Advertiser interface or not',
`hidden_for_advertiser` TINYINT(1) NOT NULL DEFAULT '0' COMMENT 'Specify if a target option is readable by Advertiser interface or not',
`hidden_for_offer` TINYINT(1) NOT NULL DEFAULT '0' COMMENT 'Specify if a target option is readable by Advertiser interface or not',
`type` VARCHAR(45) NULL DEFAULT NULL,
`is_unique_for_profile` TINYINT(1) NULL DEFAULT '0',
`is_unique_for_target` TINYINT(1) NULL DEFAULT '0',
PRIMARY KEY (`profile_option_id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `profile_option_element`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `fairtime`.`profile_option_element` (
`profile_option_element_id` INT(11) NOT NULL AUTO_INCREMENT,
`profile_option_id` INT(11) NOT NULL,
`name` VARCHAR(255) NOT NULL,
`hidden_for_user` TINYINT(1) NOT NULL DEFAULT '0' COMMENT 'Specify if a target option is readable by Advertiser interface or not',
`hidden_for_advertiser` TINYINT(1) NOT NULL DEFAULT '0' COMMENT 'Specify if a target option is readable by Advertiser interface or not',
`hidden_for_offer` TINYINT(1) NOT NULL DEFAULT '0' COMMENT 'Specify if a target option is readable by Advertiser interface or not',
`type` VARCHAR(45) NULL DEFAULT NULL,
`app_user_id` INT(11) NULL DEFAULT NULL COMMENT 'When a user creates a brand in their MyFairTime',
`approved` TINYINT(1) NOT NULL DEFAULT '0',
`created_at` DATETIME NULL DEFAULT NULL,
`boolean_value` TINYINT(1) NULL DEFAULT NULL,
PRIMARY KEY (`profile_option_element_id`, `profile_option_id`),
INDEX `fk_target_option_element_target_option1_idx` (`profile_option_id` ASC),
INDEX `fk_profile_option_element_app_user1_idx` (`app_user_id` ASC),
CONSTRAINT `fk_target_option_element_target_option1`
FOREIGN KEY (`profile_option_id`)
REFERENCES `fairtime`.`profile_option` (`profile_option_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_profile_option_element_app_user1`
FOREIGN KEY (`app_user_id`)
REFERENCES `fairtime`.`app_user` (`app_user_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `profile_has_profile_option_element`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `fairtime`.`profile_has_profile_option_element` (
`profile_profile_id` INT(11) NOT NULL,
`profile_option_element_profile_option_element_id` INT(11) NOT NULL,
`profile_option_element_profile_option_id` INT(11) NOT NULL,
PRIMARY KEY (`profile_profile_id`, `profile_option_element_profile_option_element_id`, `profile_option_element_profile_option_id`),
INDEX `fk_profile_has_profile_option_element_profile_option_elemen_idx` (`profile_option_element_profile_option_element_id` ASC, `profile_option_element_profile_option_id` ASC),
INDEX `fk_profile_has_profile_option_element_profile1_idx` (`profile_profile_id` ASC),
CONSTRAINT `fk_profile_has_profile_option_element_profile1`
FOREIGN KEY (`profile_profile_id`)
REFERENCES `fairtime`.`profile` (`profile_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_profile_has_profile_option_element_profile_option_element1`
FOREIGN KEY (`profile_option_element_profile_option_element_id` , `profile_option_element_profile_option_id`)
REFERENCES `fairtime`.`profile_option_element` (`profile_option_element_id` , `profile_option_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
–
带工作台的架构是这样的:
这是hibernate中涉及的类:
Profile.java:
–
package models.classes_hibernate;
// Generated 02/07/2014 10:54:27 by Hibernate Tools 3.6.0
import javax.persistence.*;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import static javax.persistence.GenerationType.IDENTITY;
/**
* Profile generated by hbm2java
*/
@Entity
@Table(name="profile"
,catalog="fairtime"
)
public class Profile implements java.io.Serializable {
private Integer profileId;
private AppUser appUser;
private City city;
private Date createdAt;
private Date updatedAt;
private String address;
private String phone;
private Set<ProfileHasCampaign> profileHasCampaigns = new HashSet<ProfileHasCampaign>(0);
private Set<ProfileOptionElement> profileOptionElements = new HashSet<ProfileOptionElement>(0);
private Set<Offer> offers = new HashSet<Offer>(0);
public Profile() {
}
public Profile(AppUser appUser, City city, Date createdAt, String address, String phone) {
this.appUser = appUser;
this.city = city;
this.createdAt = createdAt;
this.address = address;
this.phone = phone;
}
public Profile(AppUser appUser, City city, Date createdAt, Date updatedAt, String address, String phone, Set<ProfileHasCampaign> profileHasCampaigns, Set<ProfileOptionElement> profileOptionElements, Set<Offer> offers) {
this.appUser = appUser;
this.city = city;
this.createdAt = createdAt;
this.updatedAt = updatedAt;
this.address = address;
this.phone = phone;
this.profileHasCampaigns = profileHasCampaigns;
this.profileOptionElements = profileOptionElements;
this.offers = offers;
}
@Id @GeneratedValue(strategy=IDENTITY)
@Column(name="profile_id", unique=true, nullable=false)
public Integer getProfileId() {
return this.profileId;
}
public void setProfileId(Integer profileId) {
this.profileId = profileId;
}
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="app_user_id", nullable=false)
public AppUser getAppUser() {
return this.appUser;
}
public void setAppUser(AppUser appUser) {
this.appUser = appUser;
}
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="city_id", nullable=false)
public City getCity() {
return this.city;
}
public void setCity(City city) {
this.city = city;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name="created_at", nullable=false, length=19)
public Date getCreatedAt() {
return this.createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name="updated_at", length=19)
public Date getUpdatedAt() {
return this.updatedAt;
}
public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
@Column(name="address", nullable=false, length=45)
public String getAddress() {
return this.address;
}
public void setAddress(String address) {
this.address = address;
}
@Column(name="phone", nullable=false, length=45)
public String getPhone() {
return this.phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
@OneToMany(fetch=FetchType.LAZY, mappedBy="profile")
public Set<ProfileHasCampaign> getProfileHasCampaigns() {
return this.profileHasCampaigns;
}
public void setProfileHasCampaigns(Set<ProfileHasCampaign> profileHasCampaigns) {
this.profileHasCampaigns = profileHasCampaigns;
}
@ManyToMany(fetch=FetchType.LAZY)
@JoinTable(name="profile_has_profile_option_element", catalog="fairtime", joinColumns = {
@JoinColumn(name="profile_profile_id", nullable=false, updatable=false) }, inverseJoinColumns = {
@JoinColumn(name="profile_option_element_profile_option_element_id", nullable=false, updatable=false) })
public Set<ProfileOptionElement> getProfileOptionElements() {
return this.profileOptionElements;
}
public void setProfileOptionElements(Set<ProfileOptionElement> profileOptionElements) {
this.profileOptionElements = profileOptionElements;
}
@OneToMany(fetch=FetchType.LAZY, mappedBy="profile")
public Set<Offer> getOffers() {
return this.offers;
}
public void setOffers(Set<Offer> offers) {
this.offers = offers;
}
}
–
ProfileOptionElement.java:
–
package models.classes_hibernate;
// Generated 02/07/2014 10:54:27 by Hibernate Tools 3.6.0
import javax.persistence.*;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
/**
* ProfileOptionElement generated by hbm2java
*/
@Entity
@Table(name="profile_option_element"
,catalog="fairtime"
)
public class ProfileOptionElement implements java.io.Serializable {
private ProfileOptionElementId id;
private AppUser appUser;
private ProfileOption profileOption;
private String name;
private boolean hiddenForUser;
private boolean hiddenForAdvertiser;
private boolean hiddenForOffer;
private String type;
private boolean approved;
private Date createdAt;
private Boolean booleanValue;
private Set<Profile> profiles = new HashSet<Profile>(0);
private Set<TargetHasProfileOptionElement> targetHasProfileOptionElements = new HashSet<TargetHasProfileOptionElement>(0);
public ProfileOptionElement() {
}
public ProfileOptionElement(ProfileOptionElementId id, ProfileOption profileOption, String name, boolean hiddenForUser, boolean hiddenForAdvertiser, boolean hiddenForOffer, boolean approved) {
this.id = id;
this.profileOption = profileOption;
this.name = name;
this.hiddenForUser = hiddenForUser;
this.hiddenForAdvertiser = hiddenForAdvertiser;
this.hiddenForOffer = hiddenForOffer;
this.approved = approved;
}
public ProfileOptionElement(ProfileOptionElementId id, AppUser appUser, ProfileOption profileOption, String name, boolean hiddenForUser, boolean hiddenForAdvertiser, boolean hiddenForOffer, String type, boolean approved, Date createdAt, Boolean booleanValue, Set<Profile> profiles, Set<TargetHasProfileOptionElement> targetHasProfileOptionElements) {
this.id = id;
this.appUser = appUser;
this.profileOption = profileOption;
this.name = name;
this.hiddenForUser = hiddenForUser;
this.hiddenForAdvertiser = hiddenForAdvertiser;
this.hiddenForOffer = hiddenForOffer;
this.type = type;
this.approved = approved;
this.createdAt = createdAt;
this.booleanValue = booleanValue;
this.profiles = profiles;
this.targetHasProfileOptionElements = targetHasProfileOptionElements;
}
@EmbeddedId
@AttributeOverrides( {
@AttributeOverride(name="profileOptionElementId", column=@Column(name="profile_option_element_id", nullable=false) ),
@AttributeOverride(name="profileOptionId", column=@Column(name="profile_option_id", nullable=false) ) } )
public ProfileOptionElementId getId() {
return this.id;
}
public void setId(ProfileOptionElementId id) {
this.id = id;
}
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="app_user_id")
public AppUser getAppUser() {
return this.appUser;
}
public void setAppUser(AppUser appUser) {
this.appUser = appUser;
}
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="profile_option_id", nullable=false, insertable=false, updatable=false)
public ProfileOption getProfileOption() {
return this.profileOption;
}
public void setProfileOption(ProfileOption profileOption) {
this.profileOption = profileOption;
}
@Column(name="name", nullable=false)
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
@Column(name="hidden_for_user", nullable=false)
public boolean isHiddenForUser() {
return this.hiddenForUser;
}
public void setHiddenForUser(boolean hiddenForUser) {
this.hiddenForUser = hiddenForUser;
}
@Column(name="hidden_for_advertiser", nullable=false)
public boolean isHiddenForAdvertiser() {
return this.hiddenForAdvertiser;
}
public void setHiddenForAdvertiser(boolean hiddenForAdvertiser) {
this.hiddenForAdvertiser = hiddenForAdvertiser;
}
@Column(name="hidden_for_offer", nullable=false)
public boolean isHiddenForOffer() {
return this.hiddenForOffer;
}
public void setHiddenForOffer(boolean hiddenForOffer) {
this.hiddenForOffer = hiddenForOffer;
}
@Column(name="type", length=45)
public String getType() {
return this.type;
}
public void setType(String type) {
this.type = type;
}
@Column(name="approved", nullable=false)
public boolean isApproved() {
return this.approved;
}
public void setApproved(boolean approved) {
this.approved = approved;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name="created_at", length=19)
public Date getCreatedAt() {
return this.createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
@Column(name="boolean_value")
public Boolean getBooleanValue() {
return this.booleanValue;
}
public void setBooleanValue(Boolean booleanValue) {
this.booleanValue = booleanValue;
}
@ManyToMany(fetch=FetchType.LAZY)
@JoinTable(name="profile_has_profile_option_element", catalog="fairtime", joinColumns = {
@JoinColumn(name="profile_option_element_profile_option_element_id", nullable=false, updatable=false),
@JoinColumn(name="profile_option_element_profile_option_id", nullable=false, updatable=false) }, inverseJoinColumns = {
@JoinColumn(name="profile_profile_id", nullable=false, updatable=false) })
public Set<Profile> getProfiles() {
return this.profiles;
}
public void setProfiles(Set<Profile> profiles) {
this.profiles = profiles;
}
@OneToMany(fetch=FetchType.LAZY, mappedBy="profileOptionElement")
public Set<TargetHasProfileOptionElement> getTargetHasProfileOptionElements() {
return this.targetHasProfileOptionElements;
}
public void setTargetHasProfileOptionElements(Set<TargetHasProfileOptionElement> targetHasProfileOptionElements) {
this.targetHasProfileOptionElements = targetHasProfileOptionElements;
}
}
–
ProfileOption.java:
–
package models.classes_hibernate;
// Generated 02/07/2014 10:54:27 by Hibernate Tools 3.6.0
import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;
import static javax.persistence.GenerationType.IDENTITY;
/**
* ProfileOption generated by hbm2java
*/
@Entity
@Table(name="profile_option"
,catalog="fairtime"
)
public class ProfileOption implements java.io.Serializable {
private Integer profileOptionId;
private String name;
private boolean hiddenForUser;
private boolean hiddenForAdvertiser;
private boolean hiddenForOffer;
private String type;
private Boolean isUniqueForProfile;
private Boolean isUniqueForTarget;
private Set<Offer> offers = new HashSet<Offer>(0);
private Set<ProfileOptionElement> profileOptionElements = new HashSet<ProfileOptionElement>(0);
public ProfileOption() {
}
public ProfileOption(String name, boolean hiddenForUser, boolean hiddenForAdvertiser, boolean hiddenForOffer) {
this.name = name;
this.hiddenForUser = hiddenForUser;
this.hiddenForAdvertiser = hiddenForAdvertiser;
this.hiddenForOffer = hiddenForOffer;
}
public ProfileOption(String name, boolean hiddenForUser, boolean hiddenForAdvertiser, boolean hiddenForOffer, String type, Boolean isUniqueForProfile, Boolean isUniqueForTarget, Set<Offer> offers, Set<ProfileOptionElement> profileOptionElements) {
this.name = name;
this.hiddenForUser = hiddenForUser;
this.hiddenForAdvertiser = hiddenForAdvertiser;
this.hiddenForOffer = hiddenForOffer;
this.type = type;
this.isUniqueForProfile = isUniqueForProfile;
this.isUniqueForTarget = isUniqueForTarget;
this.offers = offers;
this.profileOptionElements = profileOptionElements;
}
@Id @GeneratedValue(strategy=IDENTITY)
@Column(name="profile_option_id", unique=true, nullable=false)
public Integer getProfileOptionId() {
return this.profileOptionId;
}
public void setProfileOptionId(Integer profileOptionId) {
this.profileOptionId = profileOptionId;
}
@Column(name="name", nullable=false)
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
@Column(name="hidden_for_user", nullable=false)
public boolean isHiddenForUser() {
return this.hiddenForUser;
}
public void setHiddenForUser(boolean hiddenForUser) {
this.hiddenForUser = hiddenForUser;
}
@Column(name="hidden_for_advertiser", nullable=false)
public boolean isHiddenForAdvertiser() {
return this.hiddenForAdvertiser;
}
public void setHiddenForAdvertiser(boolean hiddenForAdvertiser) {
this.hiddenForAdvertiser = hiddenForAdvertiser;
}
@Column(name="hidden_for_offer", nullable=false)
public boolean isHiddenForOffer() {
return this.hiddenForOffer;
}
public void setHiddenForOffer(boolean hiddenForOffer) {
this.hiddenForOffer = hiddenForOffer;
}
@Column(name="type", length=45)
public String getType() {
return this.type;
}
public void setType(String type) {
this.type = type;
}
@Column(name="is_unique_for_profile")
public Boolean getIsUniqueForProfile() {
return this.isUniqueForProfile;
}
public void setIsUniqueForProfile(Boolean isUniqueForProfile) {
this.isUniqueForProfile = isUniqueForProfile;
}
@Column(name="is_unique_for_target")
public Boolean getIsUniqueForTarget() {
return this.isUniqueForTarget;
}
public void setIsUniqueForTarget(Boolean isUniqueForTarget) {
this.isUniqueForTarget = isUniqueForTarget;
}
@ManyToMany(fetch=FetchType.LAZY)
@JoinTable(name="offer_has_profile_option", catalog="fairtime", joinColumns = {
@JoinColumn(name="profile_option_profile_option_id", nullable=false, updatable=false) }, inverseJoinColumns = {
@JoinColumn(name="offer_offer_id", nullable=false, updatable=false) })
public Set<Offer> getOffers() {
return this.offers;
}
public void setOffers(Set<Offer> offers) {
this.offers = offers;
}
@OneToMany(fetch=FetchType.LAZY, mappedBy="profileOption")
public Set<ProfileOptionElement> getProfileOptionElements() {
return this.profileOptionElements;
}
public void setProfileOptionElements(Set<ProfileOptionElement> profileOptionElements) {
this.profileOptionElements = profileOptionElements;
}
}
–
当我尝试使用hibernate时,我得到以下异常:
Unexpected exception[PersistenceException: [PersistenceUnit: fairtimePersistenceUnit] Unable to build Hibernate SessionFactory]
Caused by: org.hibernate.AnnotationException: A Foreign key refering models.classes_hibernate.ProfileOptionElement from models.classes_hibernate.Profile has the wrong number of column. should be 2
我找不到问题,提前感谢您的帮助
最佳答案 关系表profile_has_profile_option_element有多个引用profile选项元素的外键,这导致生成的类引用了该表的条目,而不是以多种方式引用配置文件中的项,这是我认为你想要的.要删除额外的外键字段,请将profile_option和profile_option_element之间的关系更改为非标识,然后重新创建与配置文件的多对多关系
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
CREATE SCHEMA IF NOT EXISTS `fairtime` ;
USE `fairtime` ;
-- -----------------------------------------------------
-- Table `fairtime`.`profile`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `fairtime`.`profile` (
`profile_id` INT(11) NOT NULL AUTO_INCREMENT,
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME NULL DEFAULT NULL,
`app_user_id` INT(11) NOT NULL,
`address` VARCHAR(45) NOT NULL,
`phone` VARCHAR(45) NOT NULL,
`city_id` INT(11) NOT NULL,
PRIMARY KEY (`profile_id`),
INDEX `fk_profile_app_user1_idx` (`app_user_id` ASC),
INDEX `fk_profile_city1_idx` (`city_id` ASC),
CONSTRAINT `fk_profile_app_user1`
FOREIGN KEY (`app_user_id`)
REFERENCES `fairtime`.`app_user` (`app_user_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_profile_city1`
FOREIGN KEY (`city_id`)
REFERENCES `fairtime`.`city` (`city_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `fairtime`.`profile_option`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `fairtime`.`profile_option` (
`profile_option_id` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`hidden_for_user` TINYINT(1) NOT NULL DEFAULT '0' COMMENT 'Specify if a target option is readable by Advertiser interface or not',
`hidden_for_advertiser` TINYINT(1) NOT NULL DEFAULT '0' COMMENT 'Specify if a target option is readable by Advertiser interface or not',
`hidden_for_offer` TINYINT(1) NOT NULL DEFAULT '0' COMMENT 'Specify if a target option is readable by Advertiser interface or not',
`type` VARCHAR(45) NULL DEFAULT NULL,
`is_unique_for_profile` TINYINT(1) NULL DEFAULT '0',
`is_unique_for_target` TINYINT(1) NULL DEFAULT '0',
PRIMARY KEY (`profile_option_id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `fairtime`.`profile_option_element`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `fairtime`.`profile_option_element` (
`profile_option_element_id` INT(11) NOT NULL AUTO_INCREMENT,
`profile_option_id` INT(11) NOT NULL,
`name` VARCHAR(255) NOT NULL,
`hidden_for_user` TINYINT(1) NOT NULL DEFAULT '0' COMMENT 'Specify if a target option is readable by Advertiser interface or not',
`hidden_for_advertiser` TINYINT(1) NOT NULL DEFAULT '0' COMMENT 'Specify if a target option is readable by Advertiser interface or not',
`hidden_for_offer` TINYINT(1) NOT NULL DEFAULT '0' COMMENT 'Specify if a target option is readable by Advertiser interface or not',
`type` VARCHAR(45) NULL,
`app_user_id` INT(11) NULL DEFAULT NULL COMMENT 'When a user creates a brand in their MyFairTime',
`approved` TINYINT(1) NOT NULL DEFAULT '0',
`created_at` DATETIME NULL,
`boolean_value` TINYINT(1) NULL DEFAULT NULL,
PRIMARY KEY (`profile_option_element_id`),
INDEX `fk_profile_option_element_app_user1_idx` (`app_user_id` ASC),
INDEX `fk_profile_option_element_profile_option1_idx` (`profile_option_id` ASC),
CONSTRAINT `fk_profile_option_element_app_user1`
FOREIGN KEY (`app_user_id`)
REFERENCES `fairtime`.`app_user` (`app_user_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_profile_option_element_profile_option1`
FOREIGN KEY (`profile_option_id`)
REFERENCES `fairtime`.`profile_option` (`profile_option_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `fairtime`.`profile_has_profile_option_element`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `fairtime`.`profile_has_profile_option_element` (
`profile_profile_id` INT(11) NOT NULL,
`profile_option_element_profile_option_element_id` INT(11) NOT NULL,
PRIMARY KEY (`profile_profile_id`, `profile_option_element_profile_option_element_id`),
INDEX `fk_profile_has_profile_option_element_profile_option_elemen_idx` (`profile_option_element_profile_option_element_id` ASC),
INDEX `fk_profile_has_profile_option_element_profile1_idx` (`profile_profile_id` ASC),
CONSTRAINT `fk_profile_has_profile_option_element_profile1`
FOREIGN KEY (`profile_profile_id`)
REFERENCES `fairtime`.`profile` (`profile_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_profile_has_profile_option_element_profile_option_element1`
FOREIGN KEY (`profile_option_element_profile_option_element_id`)
REFERENCES `fairtime`.`profile_option_element` (`profile_option_element_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
不幸的是,我没有足够的代表来发布图片