If you know that you’ll want to see all Comment
s every time you retrieve a Topic
then change your field mapping for comments
to:
@OneToMany(fetch = FetchType.EAGER, mappedBy = "topic", cascade = CascadeType.ALL) private Collection<Comment> comments = new LinkedHashSet<Comment>();
Collections are lazy-loaded by default, take a look at this if you want to know more.
Related Posts:
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘MyController’:
- Error creating bean with name ‘entityManagerFactory’ defined in class path resource : Invocation of init method failed
- Error creating bean with name ‘entityManagerFactory’ defined in class path resource : Invocation of init method failed
- Spring Boot – Unable to resolve Whitelabel Error Page
- Spring @PropertySources value not overriding
- HTTP Status 405 – Request method ‘POST’ not supported (Spring MVC)
- Spring boot – Request method ‘POST’ not supported. Tried everything
- Difference between spring @Controller and @RestController annotation
- Unable to create requested service [org.hibernate .engine.jdbc.env.spi.JdbcEnvironment]-MySQL
- @Autowired – No qualifying bean of type found for dependency
- HTTP Status 405 – Request method ‘POST’ not supported (Spring MVC)
- UnsatisfiedDependencyException: Error creating bean with name
- UnsatisfiedDependencyException: Error creating bean with name
- Why SpringMVC Request method ‘GET’ not supported?
- Spring boot: Unable to start embedded Tomcat servlet container
- model.addAttribute() parameters
- getting error HTTP Status 405 – HTTP method GET is not supported by this URL but not used `get` ever?
- What does request.getParameter return?
- Understanding Spring @Autowired usage
- com.atomikos.icatch.SysException: Error in init: Log already in use? tmlog in ./
- “NoClassDefFoundError: Could not initialize class” error
- Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
- No String-argument constructor/factory method to deserialize from String value (”)
- org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set
- “NoClassDefFoundError: Could not initialize class” error
- “NoClassDefFoundError: Could not initialize class” error
- What is difference between CrudRepository and JpaRepository interfaces in Spring Data JPA?
- 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
- What’s the difference between session.persist() and session.save() in Hibernate?
- What’s the advantage of load() vs get() in Hibernate?
- What is the difference between response.sendRedirect() and request.getRequestDispatcher().forward(request,response)
- How to resolve Error listenerStart when deploying web-app in Tomcat 5.5?
- com.sun.jdi.InvocationException occurred invoking method
- Only using @JsonIgnore during serialization, but not deserialization
- Spring Maven clean error – The requested profile “pom.xml” could not be activated because it does not exist
- What are the possible values of the Hibernate hbm2ddl.auto configuration and what do they do
- 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
- java.lang.NumberFormatException: null i
- org.apache.jasper.JasperException: Unable to compile class for JSP:
- intellij incorrectly saying no beans of type found for autowired repository
- Could not resolve placeholder in string value
- How to fix the Hibernate “object references an unsaved transient instance – save the transient instance before flushing” error
- Is spring default scope singleton or not?
- WebServlet cannot be resolved to a type
- Hibernate Error: a different object with the same identifier value was already associated with the session
- The request sent by the client was syntactically incorrect.-Spring MVC + JDBC Template
- hibernate properties not found
- What does this expression language ${pageContext.request.contextPath} exactly do in JSP EL?
- MultipartException: Current request is not a multipart request
- how to fix Cannot call sendRedirect() after the response has been committed?
- Response has aready been committed
- What is the difference between JSF, Servlet and JSP?
- How to upload a file and JSON data in Postman?
- What kind of Java type is “[B”?
- Hibernate – Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
- JsonMappingException: No suitable constructor found for type [simple type, class ]: can not instantiate from JSON object
- What’s the difference between JPA and Hibernate?
- How to map a composite key with JPA and Hibernate?
- Configure active profile in SpringBoot via Maven
- Downloading a file from spring controllers
- Static Final Long serialVersionUID = 1L
- getOutputStream() has already been called for this response
- How to specify the default error page in web.xml?
- java.lang.IllegalStateException: Failed to introspect Class
- when spring boot startup,throw out the “method names must be tokens” exception
- Hibernate show real SQL
- Spring Hibernate – Could not obtain transaction-synchronized Session for current thread
- Eclipse/Maven error: “No compiler is provided in this environment”
- Rock, Paper, Scissors Game Java
- How do I reverse an int array in Java?
- Why should a Java class implement comparable?
- Lombok and Maven
- java Arrays.sort 2d array
- what is the difference between `public class` and just `class`?
- How do I use a delimiter with Scanner.useDelimiter in Java?
- Sort a single String in Java
- Difference between slf4j-log4j12 and log4j-over-slf4j
- Java, “Variable name” cannot be resolved to a variable
- Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException
- Generating all permutations of a given string
- imageio.IIOException: Can’t read input file
- Difference between OpenJDK and Adoptium/AdoptOpenJDK
- Compile failed; see the compiler error output for details
- Java: Rotating Images
- How to create a generic array in Java?
- Print a boolean value with printf
- Meaning of @Resource annotation
- How to solve error lossy convertion from int to char?
- What does “error: ‘.class’ expected” mean and how do I fix it
- How to resolve Unable to load authentication plugin ‘caching_sha2_password’ issue
- Deleting an object in java?
- Recompile with -Xlint:deprecation for details
- Downloading Java JDK on Linux via wget is shown license page instead
- What is the purpose of Java DOT operator?
- Return outside method error
- No Spring WebApplicationInitializer types detected on classpath
- How to define a relative path in java