A hands-on learning repository documenting my journey through Java backend development. This repository contains small practice projects and experiments covering core Java backend technologies, persistence, web development, and the Spring ecosystem.
The projects are organized as individual learning modules:
- JDBC
- Servlets
- Hibernate
- Spring Core
- Spring Java Configuration
- Spring XML Configuration
- Spring JDBC
- Spring Data JPA
- Spring MVC
- Spring Boot
| Project | Topics |
|---|---|
jdbc-practice |
JDBC, database connections, SQL, CRUD |
servlet-practice |
Servlets, HTTP, Tomcat, request/response |
hibernate-practice |
Hibernate ORM, entities, sessions, persistence |
spring-java-configuration |
Spring IoC and Java-based configuration |
spring-xml-configuration |
Spring IoC and XML-based configuration |
spring-jdbc |
Spring JDBC and database access |
spring-data-jpa-demo |
Spring Data JPA and repository abstraction |
spring-boot-mvc-demo |
Spring Boot, MVC, controllers, web applications |
The JDBC practice project focuses on database connectivity and core JDBC operations using PostgreSQL.
- JDBC database connectivity with
DriverManager Connection,Statement, andResultSetexecuteQuery()andexecuteUpdate()- CRUD operations:
INSERT,SELECT,UPDATE,DELETE PreparedStatementand parameterized SQL- Batch processing with
addBatch()andexecuteBatch() - Transaction management with
commit()androllback() DatabaseMetaDataandResultSetMetaData- Try-with-resources for JDBC resource management
- Maven dependency management for the PostgreSQL JDBC driver
jdbc-practice/
├── pom.xml
└── src/
└── main/
└── java/
├── Main.java
├── ConnectionDemo.java
├── StatementDemo.java
├── CrudDemo.java
├── PreparedStatementDemo.java
├── BatchDemo.java
├── TransactionDemo.java
└── MetadataDemo.java
- Embedded Tomcat
- Servlet registration and URL mapping
- Context path vs servlet path
- HTTP request and response
HttpServletRequestHttpServletResponsedoGet(),doPost(),doPut(),doDelete()- Servlet lifecycle:
init()anddestroy()
The Servlet practice project uses embedded Tomcat and maps:
http://localhost:8080/greetings/hello
The Hibernate practice project covers ORM fundamentals, JPA entity mapping, persistence, HQL, entity lifecycle, persistence context, transactions, relationships, and fetch strategies using PostgreSQL.
- Maven project setup
- Hibernate ORM dependency configuration
- PostgreSQL JDBC driver
hibernate.cfg.xml- Database connection and dialect configuration
SessionFactorycreationSessionmanagementSessionFactorylifecycle and resource management
@Entity@Id@GeneratedValue@Column@Table- Entity-to-table mapping
- Field-to-column mapping
- Generated primary keys
SessionFactorySessionTransactionbeginTransaction()commit()rollback()- Transaction boundaries
- Basic transaction failure handling
- Transient state
- Persistent state
- Detached state
persist()detach()- Entity state transitions
- Dirty checking of persistent entities
persist()for inserting entitiesfind()for retrieving entitiesgetReference()for obtaining entity references- Updating persistent entities
- Automatic updates through dirty checking
remove()for deleting entities
- HQL
SELECT WHEREconditions- Parameterized HQL queries
LIKEORDER BY- Aggregate functions
COUNT()AVG()- HQL
JOIN JOIN FETCH
createQuery()- Typed HQL queries
setParameter()getResultList()getSingleResult()
- Persistence context
- First-level cache
- Entity identity within a persistence context
- Dirty checking
flush()refresh()clear()detach()- Synchronization between entities and the database
- Entity relationships and foreign keys
@OneToMany@ManyToOnemappedBy- Relationship ownership
- Cascade operations
- Bidirectional relationships
- Collection mapping
- Foreign-key based associations
FetchType.LAZYFetchType.EAGER- Lazy loading
- Explicit initialization of lazy associations
JOIN FETCH- Difference between lazy and eager loading
- Hibernate exception handling
- Transaction failure handling
- Rollback on operation failure
- Handling invalid entity operations
- Resource cleanup with try-with-resources
hibernate-practice/
├── pom.xml
├── src/
│ └── main/
│ ├── java/
│ │ ├── ConfigurationDemo.java
│ │ ├── CrudDemo.java
│ │ ├── EntityLifecycleDemo.java
│ │ ├── ExceptionDemo.java
│ │ ├── FetchTypeDemo.java
│ │ ├── HibernateUtil.java
│ │ ├── HqlDemo.java
│ │ ├── springcore.Laptop.java
│ │ ├── Main.java
│ │ ├── PersistenceContextDemo.java
│ │ ├── RelationshipDemo.java
│ │ ├── Student.java
│ │ └── TransactionDemo.java
│ └── resources/
│ └── hibernate.cfg.xml
The Spring Core practice project focuses on the Spring IoC container, dependency injection, bean configuration, component scanning, dependency resolution, bean scopes, and bean lifecycle management.
- Maven project setup
- Spring Context dependency
ApplicationContextAnnotationConfigApplicationContext
- Inversion of Control
- Spring IoC container
- Object creation and dependency management by Spring
BeanFactoryApplicationContext- Difference between
BeanFactoryandApplicationContext
- Dependency Injection
- Constructor Injection
- Setter Injection
- Field Injection
- Dependency resolution by type
@Configuration@Bean@ComponentScan- Component Scanning
- Explicit bean configuration
- Difference between
@Beanand@Component
@Component@Service@Repository@Controller- Role of specialized stereotype annotations
- Automatic bean detection through component scanning
@Autowired@Qualifier- Resolving multiple beans of the same type
@Primary- Constructor-based dependency resolution
- Setter-based dependency resolution
- Qualifier placement on injection points
- Singleton scope
- Prototype scope
- One singleton instance per
ApplicationContext - New prototype instance for each bean request
- Request scope — web-specific
- Session scope — web-specific
- Bean instantiation
- Constructor execution
- Initialization phase
@PostConstruct- Bean usage
@PreDestroy- Bean destruction
- ApplicationContext startup and shutdown
- Creating the
ApplicationContext - Bean creation during context startup
- Dependency injection
- Bean initialization
- Application execution
- Closing the
ApplicationContext - Bean destruction during context shutdown
context.close()
spring-core/
├── pom.xml
└── src/
└── main/
└── java/
└── springcore/
├── AppConfig.java
├── IoCDemo.java
├── DependencyInjectionDemo.java
├── SetterInjectionDemo.java
├── FieldInjectionDemo.java
├── ComponentDemo.java
├── QualifierDemo.java
├── PrimaryDemo.java
├── BeanScopeDemo.java
├── BeanLifecycleDemo.java
├── ApplicationContextLifecycleDemo.java
├── StereotypeAnnotationsDemo.java
└── BeanAnnotationDemo.java
The Spring XML configuration practice project focuses on XML-based bean configuration, dependency injection, autowiring, bean scopes, lifecycle management, and modular XML configuration.
- XML-based Spring bean configuration
ClassPathXmlApplicationContext<bean>definitions- Bean IDs and class mapping
- XML namespaces and schema configuration
- Constructor Injection using
<constructor-arg> - Setter Injection using
<property> - Dependency references using
ref - Literal value injection using
value - Difference between
refandvalue
- XML autowiring
autowire="byType"- Automatic dependency resolution by type
- Setter-based autowiring
- Singleton scope
- Prototype scope
- One singleton instance per
ApplicationContext - New prototype instance for each bean request
- Request scope — web-specific
- Session scope — web-specific
- Bean instantiation
- Initialization using
init-method - Bean usage
- Destruction using
destroy-method - ApplicationContext shutdown
- Singleton vs prototype destruction behavior
<import>for importing XML configuration files- Splitting bean definitions across multiple configuration files
- Central configuration with imported module configurations
spring-xml-configuration/
├── pom.xml
└── src/
└── main/
├── java/
│ └── springxml/
│ ├── XmlConfigDemo.java
│ ├── XmlConstructorInjectionDemo.java
│ ├── XmlSetterInjectionDemo.java
│ ├── XmlAutowireDemo.java
│ ├── XmlValueInjectionDemo.java
│ ├── XmlScopeLifecycleDemo.java
│ └── XmlImportDemo.java
└── resources/
├── applicationContext.xml
├── constructor-config.xml
├── setter-config.xml
├── autowire-config.xml
├── value-config.xml
├── scope-lifecycle-config.xml
├── common-config.xml
└── main-config.xml
The Spring JDBC practice project focuses on database access using Spring's JDBC abstraction, JdbcTemplate, PostgreSQL, parameterized queries, result mapping, and DAO-based data access.
- Maven project setup
- Spring Context configuration
- Spring JDBC dependency
- PostgreSQL JDBC driver
DataSourceconfigurationJdbcTemplateconfiguration- Dependency injection of
DataSourceintoJdbcTemplate - Environment variables for database credentials
JdbcTemplatequery()queryForObject()update()- Simplified JDBC resource management
- Executing SQL through Spring's JDBC abstraction
SELECTqueries- Single-row retrieval with
queryForObject() - Multiple-row retrieval with
query() - Parameterized SQL queries
PreparedStatementhandling throughJdbcTemplate
RowMapper- Lambda-based row mapping
- Mapping
ResultSetrows to Java objects BeanPropertyRowMapper- Mapping database columns to JavaBean properties
INSERTSELECTUPDATEDELETE- Parameterized CRUD operations
- Rows-affected result from
update()
- Data Access Object pattern
- Separation of database logic from application logic
- Constructor injection of
JdbcTemplate - DAO methods for querying and modifying data
findAll()findById()save()update()delete()
spring-jdbc/
├── pom.xml
└── src/
└── main/
└── java/
└── springjdbc/
├── JdbcConfig.java
├── JdbcTemplateDemo.java
├── QueryDemo.java
├── CrudDemo.java
├── PreparedStatementDemo.java
├── SingleRowQueryDemo.java
├── BeanPropertyRowMapperDemo.java
└── dao/
├── Laptop.java
├── LaptopDao.java
└── DaoDemo.java