In Object Oriented Programming calling constructor is the first step of initialization an object. There are 2 types of constructors – default and parameterized.
Default – Constructor that take zero argument is called Default Constructor. Every class needs a default constructor. A default (no-argument) constructor is automatically created only when you do not define one yourself.
Parameterized – Constructor that take arguments are called parameterized Constructors.
They can be added as per our requirement.
When you declare a parameterized constructor you must add default constructor as java stops creating one.
There are 2 steps involved in configuring postgres sql data base to a spring boot application assuming we already have data base setup.
- Add postgres sql dependency to pom.xml.
2. We need to tell Spring container to look into postgres by changing the
So the list of possible options for
- validate: validate the schema, makes no changes to the database.
- update: update the schema.
- create: creates the schema, destroying previous data.
- create-drop: drop the schema when the SessionFactory is closed explicitly, typically when the application is stopped.
I added spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true as the server is throwing following warning while startup.
java.sql.SQLFeatureNotSupportedException: Method org.postgresql.jdbc42.Jdbc42Connection.createClob() is not yet implemented.
Now restart server and you should see successful db connection logs. When the connection is successful spring container tries to validate the entities in the project to the db tables.
Difference between spring annotations @RestController and @Controller is
Both are used to indicate
spring container that it is a controller stereotype but for
@RestController it returns
domain object instead of a