GenerationType.IDENTITY vs GenerationType.SEQUENCE vs GenerationType.AUTO

GenerationType.IDENTITY vs GenerationType.SEQUENCE vs GenerationType.AUTO

GenerationType.IDENTITY vs GenerationType.SEQUENCE vs GenerationType.AUTO: In hibernate for the primary key/auto generated id value column we used to annotate @GeneratedValue with strategy as either of these, GenerationType.IDENTITY 2. GenerationType.SEQUENCE 3. GenerationType.AUTO   It is highly important to understand the difference between these generation types to make it fit in the right place. Suppose you have two tables namely store and coupon, store id is a primary key in store table and foreign key in coupon table. Store table: store_id |…

Read More Read More

576 total views, 8 views today

Difference between @Inject and @Autowired

Difference between @Inject and @Autowired

Difference between @Inject and @Autowired This is one of the important interview question of spring / spring boot framework interviews. Auto-wiring is the great feature we got to wire our application dependencies spring way, but it can be done by both JSR annotation and spring provided annotation. It is important to know the difference between these both to make use of it effectively in real time use-cases. @Inject: Does not have ‘required’ attribute Throws exception if the dependency not found….

Read More Read More

399 total views, 1 views today

When does spring create instances to be injected ?

When does spring create instances to be injected ?

When does spring create instances to be injected ? This is one of the famous spring / spring boot framework interview question. Spring creates the instances to be injected during the start up. If you have configured spring beans with lazy-init attribute then spring creates the instances of those bean only when you inject/any of it’s dependencies injects it. By default, Application Context creates the instances of all the beans eagerly with singleton scope during it’s initialization process only. 266 total…

Read More Read More

266 total views, 1 views today

Why StringBuffer/StringBuilder should be avoided in HashMap?

Why StringBuffer/StringBuilder should be avoided in HashMap?

Why StringBuffer/StringBuilder should be avoided in HashMap?   This is one of the core java interview question under collections category. Generally in all the map manipulations we use string and avoid stringbuffer and stringbuilders, because both are mutable. What is the issue if is mutable ? If you are keeping your hashmap’s key/value as stringbuilder/stringbuffer then once after you inserted the value in the map, if any of the key/value modified then it actually affects inside the map as well,…

Read More Read More

354 total views, no views today

[Resolved] Spring boot JWT Filter called twice

[Resolved] Spring boot JWT Filter called twice

[Resolved] Spring boot JWT Filter called twice: Recently when I was integrating JWT Filter and Simple CORS filter in my spring boot project, I observed that both the filters are called twice before actually reaching my servlet/rest controller.   After googling, I got this link, As per that, One invocation is by servlet container and the other is by Spring Security, so the filter will get called twice. So by adding this line in your JWT Filter bean implementation registrationBean.setEnabled(false);¬†only…

Read More Read More

543 total views, 2 views today

org.springframework.web.HttpMediaTypeNotAcceptableException | Could not find acceptable representation

org.springframework.web.HttpMediaTypeNotAcceptableException | Could not find acceptable representation

org.springframework.web.HttpMediaTypeNotAcceptableException | Could not find acceptable representation: Full Error details: {“timestamp”:1522250376646,”status”:406,”error”:”Not Acceptable”,”exception”:”org.springframework.web.HttpMediaTypeNotAcceptableException”,”message”:”Could not find acceptable representation”,”path”:”/category/deleteImage/google.png”}     As per this link, I found the solution for this issue:   Solution: @SpringBootApplication public class CouponzcornerBackendApplication { public static void main(String[] args) { SpringApplication.run(CouponzcornerBackendApplication.class, args); } @Configuration public static class PathMatchingConfigurationAdapter extends WebMvcConfigurerAdapter { @Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { configurer.favorPathExtension(false); } } } 704 total views, 2 views today

704 total views, 2 views today

Difference between Component & Directive in Angular

Difference between Component & Directive in Angular

Difference between Component & Directive in Angular: Component: Components can be created using @Component annotation. <app-header></app-header>, here app-header is the component. Components helps to split the application into smaller components. Only one component can be used per DOM element. <app-header app-footer></app-header app-footer> can’t do like this and all. Directive: Directive can be created using @Directive annotation. <button highLightMe>I log when clicked!</button>, here highLightMe is the directive. Directives helps to design re-usable components. [highLightMe can be used in different tags to…

Read More Read More

736 total views, 2 views today

Difference between Structural and Attribute directives in angular?

Difference between Structural and Attribute directives in angular?

What is the difference between Structural and Attribute directives ? Directives are divided into two types namely Structural and Attribute directives. These are the differences: Structural directives: It changes the structure of the DOM. * is prefixed to the structural directives. *ngIf, *ngFor are the examples of structural directives.   Attribute directives: It just changes the appearance of the DOM. It is not prefixed with *. ngClass, ngStyle are the examples of attribute directives. 948 total views, 4 views today

948 total views, 4 views today

All about pipe in angular 5 for dummies (custom pipe | pure | impure pipes)

All about pipe in angular 5 for dummies (custom pipe | pure | impure pipes)

All about pipe in angular 5 for dummies (custom pipe | pure | impure pipes) We can create our custom pipes with the below steps: Create the typescript class with @Pipe decorator 2. Provide the name of the pipe to the @Pipe decorator’s name property. 3. Implement the class with PipeTransform 4. Provide the implementation of the pipe functionality inside the transform method. 5. transform is the method need to be used for any custom pipes and the same needs…

Read More Read More

454 total views, 2 views today

[Resolved] “org.springframework.web.HttpMediaTypeNotSupportedException” angular 5

[Resolved] “org.springframework.web.HttpMediaTypeNotSupportedException” angular 5

Hi All,¬†Recently I came across this “org.springframework.web.HttpMediaTypeNotSupportedException” error while trying to hit my spring boot rest web services application from angular 5.   I am posting my experience because to help someone quickly. I almost cross checked all the places many times, but I could not find the below miss which I found at last and also do remember this error says that “HttpMediaTypeNotSupportedException”, so this error can happen due to incorrect media type/media type is not set or some…

Read More Read More

406 total views, 1 views today