I am here trying to fetch data using the primary key as one(1) from the database using JPA. but here data is not printing in the console after the query is successfully run. Here is the code:
public void getMobData() {
Optional<Mobile> getMobile_Data = mobileRepo.findById(1);
if(getMobile_Data.isPresent())
{System.out.println("Data is present::"+getMobile_Data.get());}
}
Output:
Hibernate: select m1_0.model_id,m1_0.mobile_company,m1_0.model_name,m1_0.year from mobile m1_0 where m1_0.model_id=?
**Data is present::com.Mapping.Entity.Mobile@79c849c7**
[2m2023-08-26T13:34:10.441+05:30[0;39m [32m INFO[0;39m [35m41892[0;39m [2m---[0;39m [2m[ionShutdownHook][0;39m [36mj.LocalContainerEntityManagerFactoryBean[0;39m [2m:[0;39m Closing JPA EntityManagerFactory for persistence unit 'default'
[2m2023-08-26T13:34:10.445+05:30[0;39m [32m INFO[0;39m [35m41892[0;39m [2m---[0;39m [2m[ionShutdownHook][0;39m [36mcom.zaxxer.hikari.HikariDataSource [0;39m [2m:[0;39m HikariPool-1 - Shutdown initiated...
[2m2023-08-26T13:34:10.464+05:30[0;39m [32m INFO[0;39m [35m41892[0;39m [2m---[0;39m [2m[ionShutdownHook][0;39m [36mcom.zaxxer.hikari.HikariDataSource
What is the mistake, and how do I fix it?