java - JPA: Column 'AdressId' cannot be null -


I am trying to continue the school unit which has a unidirectional address with an address, but I Getting Column 'AdressId' can not be redundant, note that MySQL DB prepares the ID for the school and here is my code of address: in JSF, when the submit button is clicked on createSchool The method is implemented.

  @NominatedApplied Public class school AddBacking applies Serializable {Private Static Last Long Serial VERSIONUID = 1L; Private static final string INSCRIPTION_RETURN = "/login.xhtml?faces-redirect=true"; Private static final string RB_Name = "bundle message"; Personal static final string USER_NOT_FOUND = "user.not.found"; Private string user email; Personal user user; Private school school; Private address address; EJB Private School PR School; @EJBPrivate UserPro UserPro; Add Public Schools () {School = New School (); Adress = new adresse (); School .Setphone Bonus (New Hashmop & lt; Phone Type School, String & gt; ()); } Create Public String School () {userEmail = getRequest () GetUserPrincipal () GetName (); Println (USEREMAIL); Try {User = userPr.getUserByEmail (userEmail); } Hold (exception E1) {getContext () addMessage (zero, new FacesMessage (ResourceBundleLoader.getBundle (RB_Name, USER_NOT_FOUND)) ;. //Del Debug} school.setUser (user); School.setAdresse (address); System.out.println ("1:" + adress.getCountry ()); System.out.println ("2:" + school.getAdresse (.) GetCountry ()); SchoolPr.createSchool (school); Return INSCRIPTION_RETURN; } + Gators & amp; Stalls for school & amp; Public Class School SerialJoble {Private Static Final} [ad: Long SerialWarsianUID = 1L; @ ID Private BigInteger ID; The name of the private string; @ManyToOne (fetch = FetchType.EAGER, Alternatives = False) @JoinColumn (name = "userId") Personal User User; @OneToOne (speed = FetchType.LAZY, cascade = CascadeType.ALL, optional = false) @JoinColumn (name = "adressId", referencedColumnName = "ID") private Adresse Adresse; @ Temporal (Temral type.dtd) Private date creation date; @ElementCollection @CollectionTable (name = "SCHOOL_PHONE") @MapKeyEnumerated (EnumType.STRING) @MapKeyColumn (name = "PHONE_TYPE") @Column (name = "PHONE_NUM") private Map & LT; PhoneTypeSchool, String & gt; phone number; @column (name = "JOIN_DATE") joining a private timestamp;  

Adresse unit:

  @ Antiti @ table (schema = "school" name = "Address") applicable public square Adresse JavakiokSerializable Does {Personal Static Last Long SerialVersionUID = 1L; @ ID / Generated Values ​​(strategy = GenerationType.AUTO) Private Bigtiger Id; Private string country; Private string state; Private string city; Private string road; Private string number; Private string zip;  

Update: If @GeneratedValue (strategy = GenerationType.AUTO) is used I:

  Avertissement: Local Exception Stack: Exception [EclipseLink-4002 ] (Eclipse persistence services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException internal exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: table 'mysql.sequence' does not exist error code : 1146 Call: Update SEQUENCE SEQ_COUNT = SEQ_COUNT +? WHERE SEQ_NAME =? Bind = & gt; [2 binding standards] Q: DataModifyQuery (name = "sequence" SQL = "? Update SEQUENCE set SEQ_COUNT = SEQ_COUNT + Where SEQ_NAME =") on org.eclipse.persistence.exceptions.DatabaseException.sqlException (DatabaseException.java:331) < / Code> 

I change it to auto identify and now it works.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -