You should include cascade="all"
(if using xml) or cascade=CascadeType.ALL
(if using annotations) on your collection mapping.
This happens because you have a collection in your entity, and that collection has one or more items which are not present in the database. By specifying the above options you tell hibernate to save them to the database when saving their parent.
Related Posts:
- How to fix the Hibernate “object references an unsaved transient instance – save the transient instance before flushing” error
- PersistentObjectException: detached entity passed to persist thrown by JPA and Hibernate
- What’s the difference between JPA and Hibernate?
- How to map a composite key with JPA and Hibernate?
- Error creating bean with name ‘entityManagerFactory’ defined in class path resource : Invocation of init method failed
- Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
- org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set
- Error creating bean with name ‘entityManagerFactory’ defined in class path resource : Invocation of init method failed
- How to fix org.hibernate.LazyInitializationException – could not initialize proxy – no Session
- org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set
- org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set
- Hibernate show real SQL
- HTTP Status 405 – Request method ‘POST’ not supported (Spring MVC)
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘MyController’:
- What is difference between CrudRepository and JpaRepository interfaces in Spring Data JPA?
- Unable to create requested service [org.hibernate .engine.jdbc.env.spi.JdbcEnvironment]-MySQL
- Spring Data JPA Update @Query not updating?
- What’s the difference between session.persist() and session.save() in Hibernate?
- What’s the advantage of load() vs get() in Hibernate?
- HTTP Status 405 – Request method ‘POST’ not supported (Spring MVC)
- What Java ORM do you prefer, and why?
- What are the possible values of the Hibernate hbm2ddl.auto configuration and what do they do
- No Persistence provider for EntityManager named
- Hibernate Error: a different object with the same identifier value was already associated with the session
- How to solve the “failed to lazily initialize a collection of role” Hibernate exception
- hibernate properties not found
- Hibernate throws org.hibernate.AnnotationException: No identifier specified for entity: com..domain.idea.MAE_MFEView
- What kind of Java type is “[B”?
- Hibernate – Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
- JPA or JDBC, how are they different?
- Spring Boot – Cannot determine embedded database driver class for database type NONE
- What does Java option -Xmx stand for? [duplicate]
- Finding white rectangle in an image
- How to use the toString method in Java?
- How to remove the last character from a string?
- Java : Comparable vs Comparator [duplicate]
- Convert int to char in java
- Change date format in a Java string
- Converting String to “Character” array in Java
- Java – What does “\n” mean? [duplicate]
- must declare a named package eclipse because this compilation unit is associated to the named module
- How can I prevent java.lang.NumberFormatException: For input string: “N/A”?
- Compiled vs. Interpreted Languages
- How to round up to the next integer?
- Spring @PropertySources value not overriding
- Array ArrayList python equivalent
- How to check if an int is a null
- How do I apply the for-each loop to every character in a String?
- Session TimeOut in web.xml
- Java – removing first character of a string
- How to send a Map in JSON
- Getting java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory exception
- Explain the use of a bit vector for determining if all characters are unique
- Exception in thread “main” java.lang.NumberFormatException: For input string: “S”
- Java Console Prompt for ENTER input before moving on [duplicate]
- Maven: Failed to read artifact descriptor
- The system cannot find the file specified in java
- Java Generate Random Number Between Two Given Values
- Causes of getting a java.lang.VerifyError
- “Unmappable character for encoding UTF-8” error
- UnsatisfiedDependencyException: Error creating bean with name
- Random shuffling of an array
- How to convert int[] to Integer[] in Java?
- How to sort an array of objects in Java?
- Filling a 2D array in Java
- How to compress a String in Java?
- java.lang.ClassNotFoundException: org.sqlite.JDBC error in Sample.java program from xerial
- How can I truncate a double to only two decimal places in Java?
- Cannot resolve symbol “Intent”
- What is the default initialization of an array in Java?
- java sort using anonymous class
- How to create a popup window in javafx
- java – How to handle array:Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 3
- How to print the data in byte array as characters?
- An established connection was aborted by the software in your host machine tomcat jackson
- Generate a random double in a range
- How to open a new tab using Selenium WebDriver in Java?
- Selenium Webdriver: Element Not Visible Exception
- Whitespace Matching Regex – Java
- Unreachable code in eclipse
- “Field can be converted to a local variable” message appearing when setting Android ActionBar colour
- Android Emulator: Unfortunately App has stopped
- Can we execute a java program without a main() method? [duplicate]
- How to really read text file from classpath in Java
- Java command not found on Linux
- Selenium using Java – The path to the driver executable must be set by the webdriver.gecko.driver system property
- How to break out or exit a method in Java?
- Java Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException
- Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/JDBC_DBO]]
- How to use labels in java code?
- How to call a variable in another method?
- javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake during web service communicaiton
- How to get Java to wait for user Input
- Java using enum with switch statement
- Removing double quotes from a string in Java
- What is inverse function to XOR?
- Java Swing revalidate() vs repaint()
- Append a single character to a string or char array in java?
- for each loop in groovy
- Details of difference between @see and @inheritDoc