Skip to content
Advertisement

Tag: spring

Jackson JSON do not wrap attributes of nested object

I’ve got following classes: When I serialize Container class using Jackson I get But I need the result to be: Is it possible (without adding Container.getDataId() method)? If so, how to do it? update I’ve tried to create custom JsonSerializer<Data> but the result was same as before I’ve also tried to add @JsonSerialize annotation above Data class, then above getter

An alternative to @Value annotation in static function

It’s not possible to use @Value on a static variable. When I do this, 0 is printed. So what is a good alternative to this? Answer Spring inject noting in static field (by default). So you have two alternatives: (the better one) make the field non static (the ugly hack) add an none static setter which writes in the static

How to use object oriented programming with Hibernate?

While using ORM tools such as Hibernate, I’ve found it is advantageous to keep all business logic out of my business objects and instead keep it in a service layer. The service layer creates the business object POJOs, manipulates them, and uses DAOs to save them. But isn’t this in a way taking a step backwards from the object oriented

when is a spring bean instantiated

In the above, when are the beans instantiated, when the ApplicationContext is created or when the getBean() is called? Answer Assuming the bean is a singleton, and isn’t configured for lazy initialisation, then it’s created when the context is started up. getBean() just fishes it out. Lazy-init beans will only be initialised when first referenced, but this is not the

How do I retrieve default validation messages from Hibernate Validator?

I’m trying to retrieve a default validation error-message using MessageSource. The code I’m working with uses reflection to retrieve the value of the message parameter. On a constraint that does not override the message parameter, I would like to retrieve the default error message. When I invoke the message method on the validation annotation, I get {org.hibernate.validator.constraints.NotBlank.message} (for example, for

How to monitor slow SQL queries executed by JPA and Hibernate

Is there any Hibernate property I could set to see all the slow queries? I’, interested in queries that take too much time to return the result set. I’m using Spring with Hibernate, configured via an applicationContext.xml Spring configuration file. Answer I have 2 suggestions: you could use Oracle’s Statspack. you could use some kind of JDBC proxy driver logging

“unable to locate Spring NamespaceHandler” error

I’m creating a stand-alone Sava application with Spring, to handle the JDBC access. The application works fine on every test and I decided that I need a jar to be deployed our clients. They might not have spring in their classpath, so I used maven-assembly-plugin to handle the jar creation with dependencies. However when I try to run the application:

Advertisement