spring-json

How to force Initialize a Hibernate JPA proxy to use it in a JSON call

允我心安 提交于 2019-12-10 03:05:58
问题 I have a Spring 3 + JPA 2.0 application. In my @Controller I need an initialized object, but I have proxies , I need to be able to initialize it programmatically. I need functionality similar to org.hibernate.Hibernate.initialize(Object) . Can someone help . The object is used for AJAX operations. If the properties are proxies I cannot send it as JSON 回答1: No JPA option to my knowledge. You should use Hibernate.initialize(..) . In fact, when I took a look at the hibernate implementation, lazy

How to force Initialize a Hibernate JPA proxy to use it in a JSON call

柔情痞子 提交于 2019-12-05 03:28:43
I have a Spring 3 + JPA 2.0 application. In my @Controller I need an initialized object, but I have proxies , I need to be able to initialize it programmatically. I need functionality similar to org.hibernate.Hibernate.initialize(Object) . Can someone help . The object is used for AJAX operations. If the properties are proxies I cannot send it as JSON No JPA option to my knowledge. You should use Hibernate.initialize(..) . In fact, when I took a look at the hibernate implementation, lazy collections appear to be initialized in many cases that one wouldn't expect. Like entityManager.contains(..

Spring 4.0.x JSON/Ajax HTTP/1.1 406 Not Acceptable

旧时模样 提交于 2019-12-02 16:31:39
问题 I am working with Spring 4.0.5.RELEASE, Spring MVC through only Java Config I have in my pom.xml the following: <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-mapper-asl</artifactId> <version>${jackson.version}</version> </dependency> Where <jackson.version>1.9.13</jackson.version> I am using the Spring default configuration about JSON. In some @Controller I have the following: @RequestMapping(value="/getjsonperson", method=RequestMethod.GET, produces=MediaType

Spring 4.0.x JSON/Ajax HTTP/1.1 406 Not Acceptable

让人想犯罪 __ 提交于 2019-12-02 07:34:07
I am working with Spring 4.0.5.RELEASE, Spring MVC through only Java Config I have in my pom.xml the following: <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-mapper-asl</artifactId> <version>${jackson.version}</version> </dependency> Where <jackson.version>1.9.13</jackson.version> I am using the Spring default configuration about JSON. In some @Controller I have the following: @RequestMapping(value="/getjsonperson", method=RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Person getJSONPerson(){ logger.info("getJSONPerson -

Spring JSON causes problems when the Spring framework is upgraded from 3.0.2 to 3.2.0

混江龙づ霸主 提交于 2019-11-29 16:49:00
I was working with a web application using the Spring framework version 3.0.2 along with Hibernate (NetBeans 6.9.1). Later I came to know that there was one of bugs that was causing problems in uploading multiple files as mentioned in my one of previous questions . I have finished struggling to acquire the solution but couldn't succeed. Therefore, I upgraded the Spring version to 3.2.0 . With the earlier version (3.0.2), AJAX was working fine with Jackson 1.9.8 (its download page ) but with the later version (3.2.0), everything works fine but AJAX calls alert an error everywhere in the

Spring MVC - HttpMediaTypeNotAcceptableException

匆匆过客 提交于 2019-11-26 04:46:50
问题 I keep getting this HttpMediaTypeNotAcceptableException error for AJAX requests when using with Spring MVC and JSON.. full stack trace of the error is.. org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodInvoker.writeWithMessageConverters(AnnotationMethodHandlerAdapter.java:1032) org.springframework.web.servlet.mvc.annotation