Skip to content
Advertisement

Tag: spring

How can I get a Spring bean in a servlet filter?

I have defined a javax.servlet.Filter and I have Java class with Spring annotations. I want to get the bean UsersConnectionRepository in my Filter, so I tried the following: But it always returns null. How can I get a Spring bean in a Filter? Answer Try: Where usersConnectionRepository is a name/id of your bean in the application context. Or even better:

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

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

Advertisement