java - hibernate - disables MySQLIntegrityConstraintViolationException -


There is a way to disable this during insert / delete

status: I have a masterDB And a library 1 db and library 2 db

Library 1 DB and Library 2 DB are two separate databases but there is only one schema because each library should have its own database. Now we have a masterDB, it has all the data in all the libraries (library1DB and library2DB ), Is still an integrated version of taking notes of their own IDs and mapping them to their library IDs.

Is the structure here in my book model in MasterDB?

Book.java

  @ ID @ Generated Values ​​(strategy = generation type AOTO) Private long master ID; @ Column Private Long ID; @column private string title; @OneToMany (Cascade = Cascade TypeL, fetch = FetchType.LAZY, mapped = "book") Personal list & amp;; Bookcur history & gt; BookCoverHistory; @ManyToOne (fetch = FetchType.LAZY) @JoinColumn (name = "LIBRARY_ID") Private Library Library;  

This is all good and good.

However, when I am putting a data in my BookCoverHistory, I am getting an exception below.

BookCoverHistory.java

  @ ID @ Generated Values ​​(strategy = generation type AOTO) Private long master ID; @ Column Private Long ID; @ManyToOne (fetch = FetchType.LAZY) @JoinColumn (name = "BOOK_ID") Private Book Book; @columnsprint string des;  

The exception is here:

  com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraint violation violation: a child line can not be added or updated Is: a foreign key constraint failed (`master_db`.` Book_cover_history`, blocking 'FK_10ggatm9ptqayo4naj23329rc`, foreign_keyword (`book_id`) reference` book` (`master_id`))  

I thought, I just disabled obstacles because I am not very specific for them because I have collected data on my libraries only in my master dib I am doing the manual and not manually operating the CRUD, but through the sinking process.

You can not disable the hibernate interrupt check, because hibernate shows an error that is basically Was thrown by your database.

You are probably using the same database connection to insert data. But as you said that you have many DBs, you have to get connection / session for your second database. If the table is well-defined, you can insert it without reference to other books.

In addition, you must delete the add, because they are only for tables in a single column. If you do not share the same database (and thus session) in tables, you need to include books and covers manually.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -