Wednesday, July 31, 2019

How to solve the windows update hanging at "Gear" icon in Windows10?

Windows 10 needs to have windows update installed regularly.
Sometimes, updates are not getting downloaded without visible reasons.
One important service for Windows Update is "Windows Update Medic Service".

  • Open the Registry Editor by executing regedit command.
  • Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WaaSMedicSvc in registry editor.
  • Double-click on Start registry DWORD to modify its Value data in right pane.
  • Set the Value data to 4 to disable Windows Update Medic Service (1 to enable that service)
  • Click "OK". Close Registry Editor and restart the machine to make changes effective.

Monday, July 1, 2019

How to keep track the changes to JPA in Spring Boot?

We develop the LOB software of different domain and almost every app use backend database to persist the data. In Java, JPA is widely use for ORM layer in between of app and database. In many occasions, CRUD logging is part of the basic requirement.
One common scenario is application needs to keep track of price change on a particular stock item within a year. It start with $25 initially and increase to $30 in a month. After 3 months, it goes down a little bit to $28 due to excess supply. In following month, it goes back to $30 thanks to higher demand and etc.
Most probably, this kind of information is useful for the end-users and our application needs to support this.
Of course, we can implement this feature by hard-coding each updates to the database, can't we ???
But, we have better option with JPA Entity Listeners. We can easily bind the event listener and persist each changes to database. It is simple and easy to implement with the help of Spring Boot.
Create a new Spring Boot application. Assume we have the following in file.
spring.datasource.url = jdbc:mysql://localhost:3306/jpa-logger?useSSL=false
spring.datasource.username = test
spring.datasource.password = test = org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.ddl-auto = create
Detail implementation is as followed.
This is REST controller which is for testing JPA logging feature

AutowireUtil class is used to auto-wire spring-beans inside JPA listener

This is the base class for all model which require the JPA logging for CRUD action.

This is Employee class which inherit from BaseModel.

This is the meta information of CRUD event to be logged into database.

This is the listener class which persist the CRUD meta information into database.

This class inject auto-wire the bean for listener.

Image compression using C#

Sometimes, we need to compress the image files while maintaining the image quality. This can be achieved by the following C# implementation....