<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tejas kasare on Medium]]></title>
        <description><![CDATA[Stories by Tejas kasare on Medium]]></description>
        <link>https://medium.com/@tejaskasare14?source=rss-56007671186f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*pR5lQuNikI5gtwHA8OPZkA.jpeg</url>
            <title>Stories by Tejas kasare on Medium</title>
            <link>https://medium.com/@tejaskasare14?source=rss-56007671186f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 11:08:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tejaskasare14/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Full Stack Java Interview Questions]]></title>
            <link>https://medium.com/@tejaskasare14/full-stack-java-interview-questions-4c948c9bb59f?source=rss-56007671186f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c948c9bb59f</guid>
            <dc:creator><![CDATA[Tejas kasare]]></dc:creator>
            <pubDate>Sun, 01 Mar 2026 17:50:25 GMT</pubDate>
            <atom:updated>2026-03-01T19:14:55.472Z</atom:updated>
            <content:encoded><![CDATA[<h3>HTML</h3><ol><li>What is HTML and why is it used?</li><li>What is the difference between HTML and CSS?</li><li>What are HTML elements and what are the different types of elements</li><li>Which tags are used to display text in HTML?</li><li>What are text formatting tags in HTML?</li><li>What are the different types of lists in HTML?</li><li>How do you display images in HTML?</li><li>How do you create hyperlinks in HTML?</li><li>What are the different types of input fields in an HTML form?</li><li>Which tags are required to create a table in HTML? Explain all table-related tags.</li></ol><h3>CSS</h3><ol><li>Types of cssWhat is CSS and why is it used?</li><li>What are the different types of CSS?</li><li>What are the different types of selectors in CSS?</li><li>What is the difference between text properties and font properties in CSS?</li><li>What is the difference between margin and padding?</li><li>What is Flexbox in CSS?</li><li>What is Grid in CSS?</li><li>What is the difference between Flexbox and Grid?</li><li>How can we add online and offline fonts in CSS?</li><li>What are media queries and why are they used?</li></ol><h3>JAVSCRIPT</h3><ol><li>What is JavaScript and what are its types?</li><li>What are the differences between var, let, and const?</li><li>What are the different data types in JavaScript?</li><li>What are operators in JavaScript?</li><li>What is the use of conditional statements in JavaScript?</li><li>What is the difference between for loop, while loop, and do-while loop</li><li>What is the difference between break and continue?</li><li>What is an array in JavaScript?</li><li>What are the commonly used array methods?</li><li>What are map(), filter(), and reduce() methods?</li><li>What is a string in JavaScript and what are string methods?</li><li>What is an object in JavaScript?</li><li>What is the difference between arrays and objects?</li><li>What is a function and what are the different types of functions?</li><li>What is a callback function?</li><li>What is a higher-order function?</li><li>What is array destructuring and what are its rules?</li><li>What is object destructuring and what are its rules?</li><li>What are rest and spread operators?</li><li>What is the DOM and what are its commonly used functions?</li><li>How do you handle a button click using JavaScript?</li><li>How do you change text content using JavaScript?</li><li>How do you create an element dynamically using JavaScript?</li><li>What is event propagation and event delegation?</li><li>What is the Fetch API?</li><li>What is the async/await pattern?</li></ol><h3>REACT</h3><ol><li>What is React and what are its main features?</li><li>How do you create a React project?</li><li>What is Babel and why is it used in React?</li><li>What is a component in React and how do you create one?</li><li>How do you create elements in React?</li><li>What is useState and how does it work?</li><li>What is useEffect and when is it used?</li><li>How do you pass data between components in React?</li><li>What is Context in React and why do we need it?</li><li>How do you create and use Context in React?</li><li>How do you implement routing in React?</li><li>What is Outlet in React Router?</li><li>What is the difference between an anchor tag and a Link component in React?</li><li>How do you handle forms in React?</li><li>What is React Hook Form (RHF) and how is it used?</li></ol><h3>SQL — DDL</h3><ol><li>Write a query to create a database named t223.</li><li>Write a query to display all available databases.</li><li>How do you select a specific database for use?</li><li>Write a query to delete a database.</li><li>What is the difference between CREATE, DROP, and USE commands</li><li>What is the purpose of the SHOW and DESCRIBE commands?</li><li>Write the general syntax to create a table in SQL.</li><li>What are the different categories of data types in SQL?</li><li>Explain numeric data types with examples.</li><li>Explain character data types with examples.</li><li>What is the difference between CHAR and VARCHAR?</li><li>Which data types do not require size definition?</li><li>Create a table named student with column rollNo of type INT.</li><li>Create a table named employee with columns: id (INT), name (VARCHAR of size 20)</li><li>What are constraints in SQL?</li><li>What is a Primary Key? Explain its properties.</li><li>Can a Primary Key accept NULL values? Why?</li><li>What is Auto Increment? Where can it be used?</li><li>What is a Foreign Key?</li><li>What is the purpose of the CHECK constraint?</li><li>Write a table query where age must be greater than 18.</li><li>What is the DEFAULT constraint? Give example.</li><li>What is the difference between NULL and NOT NULL?</li><li>What is ENUM? Give a real-life example.</li><li>What is SET?</li><li>How is it different from ENUM?</li><li>What is UNIQUE constraint?</li><li>What is the difference between PRIMARY KEY and UNIQUE?</li><li>What is the use of the ALTER command?</li><li>Write a query to add a new column age to employee table.</li><li>Write a query to add a column salary after name.</li><li>Write a query to add a Primary Key column at the first position.</li><li>Write a query to modify column size from VARCHAR(20) to VARCHAR(30).</li><li>Write a query to change salary column datatype from FLOAT to VARCHAR(20).</li><li>Write a query to drop a column from a table.</li><li>Write a query to rename a column.</li><li>Write a query to rename a table.</li><li>What is the difference between MODIFY and CHANGE (if applicable in MySQL)?</li><li>What is data integrity?</li><li>Why are constraints important?</li><li>Can a table have multiple Primary Keys?</li><li>Can a table have multiple UNIQUE constraints?</li><li>What is the difference between ENUM and SET?</li><li>What is the difference between NULL and empty string?</li><li>What happens if we drop a table?</li><li>What happens if we drop a database?</li><li>what is data and database?</li><li>what is difference between SQL and MYSQL?</li><li>what is structured VS unstructured data?</li></ol><h4>SQL — CONSTRAINTS</h4><ol><li>what is constraints? explain all constraints with one example each</li><li>Write a query to create an employee table with the following constraints:</li></ol><ul><li>ssd</li></ul><p>3. sdsa</p><ul><li>id as Primary Key with Auto Increment</li><li>name as NOT NULL</li><li>designation as NULL</li><li>age with CHECK constraint (age ≥ 18)</li><li>salary with DEFAULT value 0</li><li>phone as UNIQUE</li><li>gender as ENUM (male, female)</li><li>skill as SET (java, sql, react)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c948c9bb59f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript Array and Object Destructing]]></title>
            <link>https://medium.com/@tejaskasare14/javascript-array-and-object-destructing-0056604866fd?source=rss-56007671186f------2</link>
            <guid isPermaLink="false">https://medium.com/p/0056604866fd</guid>
            <category><![CDATA[array-destructuring]]></category>
            <category><![CDATA[object-destructuring]]></category>
            <category><![CDATA[javascript-rest-operator]]></category>
            <category><![CDATA[spread-operator]]></category>
            <dc:creator><![CDATA[Tejas kasare]]></dc:creator>
            <pubDate>Tue, 12 Nov 2024 11:49:32 GMT</pubDate>
            <atom:updated>2024-11-12T11:50:30.595Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BCtxoa2InpbdBo92b3X9xg.png" /></figure><p>JavaScript destructuring allows you to unpack values from arrays or properties from objects into distinct variables, which can make your code cleaner and more readable.</p><h3><strong>1. Array Destructuring</strong></h3><p>In array destructuring, you extract values from an array and assign them to variables in a convenient way. Here’s the basic syntax:</p><pre>const array = [1, 2, 3];<br><br>// Destructuring<br>const [a, b, c] = array;<br><br>console.log(a); // 1<br>console.log(b); // 2<br>console.log(c); // 3</pre><h4><strong>1.1 Skipping Elements in array destrucring</strong></h4><p>You can skip elements in an array by leaving the spot empty:</p><pre>const array = [1, 2, 3, 4];<br><br>// Skip the second element<br>const [first, , third] = array;<br><br>console.log(first); // 1<br>console.log(third); // 3</pre><h4>1.2 Default Values in array destrucring</h4><p>If the array has fewer elements than expected, you can assign default values:</p><pre>const array = [1];<br><br>// Set default for missing elements<br>const [a, b = 2] = array;<br><br>console.log(a); // 1<br>console.log(b); // 2</pre><h4>1.3 Rest operator in array destrucring</h4><p>You can collect the remaining elements of the array using the rest syntax (...):</p><pre>const array = [1, 2, 3, 4];<br><br>// Collect remaining elements into `rest`<br>const [first, second, ...rest] = array;<br><br>console.log(first);  // 1<br>console.log(second); // 2<br>console.log(rest);   // [3, 4]</pre><h3>2. Object Destructuring</h3><p>In object destructuring, you extract properties from an object and assign them to variables. The syntax is based on the property names.</p><pre>const person = { name: &#39;John&#39;, age: 30 };<br><br>// Destructuring<br>const { name, age } = person;<br><br>console.log(name); // John<br>console.log(age);  // 30</pre><h4>2.1 Renaming Variables in object destruring</h4><p>If you want to rename the variables while destructuring, you can do this:</p><pre>const person = { name: &#39;John&#39;, age: 30 };<br><br>// Rename &#39;name&#39; to &#39;fullName&#39; and &#39;age&#39; to &#39;yearsOld&#39;<br>const { name: fullName, age: yearsOld } = person;<br><br>console.log(fullName);  // John<br>console.log(yearsOld);  // 30</pre><h4>2.3 Default Values in object destructuring</h4><p>If an object does not have a specific property, you can assign a default value:</p><pre>const person = { name: &#39;John&#39; };<br><br>// Set default value for missing &#39;age&#39;<br>const { name, age = 25 } = person;<br><br>console.log(name); // John<br>console.log(age);  // 25</pre><h4>2.4 Nested Object Destructuring</h4><p>You can destructure nested objects by using a similar syntax inside the curly braces:</p><pre>const person = {<br>  name: &#39;John&#39;,<br>  address: {<br>    city: &#39;New York&#39;,<br>    zip: &#39;10001&#39;<br>  }<br>};<br><br>// Destructuring nested object<br>const { name, address: { city, zip } } = person;<br><br>console.log(name);  // John<br>console.log(city);  // New York<br>console.log(zip);   // 10001</pre><h4>2.5 Rest Syntax in Object destructuring</h4><p>The rest syntax (...) can also be used to collect the remaining properties into a new object:</p><pre>const person = { name: &#39;John&#39;, age: 30, gender: &#39;male&#39; };<br><br>// Collect remaining properties into `other`<br>const { name, ...other } = person;<br><br>console.log(name);   // John<br>console.log(other);  // { age: 30, gender: &#39;male&#39; }</pre><h3>3. Combining Array and Object Destructuring</h3><p>You can combine array and object destructuring when working with complex data structures</p><pre>const data = [<br>  { name: &#39;John&#39;, age: 30 },<br>  { name: &#39;Jane&#39;, age: 25 }<br>];<br><br>// Destructure array of objects<br>const [{ name: name1, age: age1 }, { name: name2, age: age2 }] = data;<br><br>console.log(name1, age1); // John 30<br>console.log(name2, age2); // Jane 25</pre><h3>4. Function Parameters with Destructuring</h3><p>Destructuring is very useful when working with function parameters, especially when passing objects or arrays.</p><h4>4.1 Object Destructuring in Function Parameters</h4><pre>const printPersonInfo = ({ name, age }) =&gt; {<br>  console.log(`${name} is ${age} years old`);<br>};<br><br>const person = { name: &#39;John&#39;, age: 30 };<br><br>printPersonInfo(person); // John is 30 years old</pre><h4>4.2 Array Destructuring in Function Parameters</h4><pre>const sum = ([a, b]) =&gt; a + b;<br><br>const result = sum([5, 7]);<br><br>console.log(result); // 12</pre><h3>5. Conclusion</h3><p>JavaScript destructuring helps you unpack values from arrays or objects in a clean and efficient way. You can:</p><ul><li><em>Destructure arrays and objects in simple or nested structures.</em></li><li><em>Assign default values for missing properties or elements.</em></li><li><em>Skip elements in arrays or collect the remaining items with the rest syntax.</em></li><li><em>Rename properties while destructuring.</em></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0056604866fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL 4 — DML]]></title>
            <link>https://medium.com/@tejaskasare14/sql-4-dml-4d969ce6ac92?source=rss-56007671186f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d969ce6ac92</guid>
            <dc:creator><![CDATA[Tejas kasare]]></dc:creator>
            <pubDate>Wed, 27 Sep 2023 11:13:52 GMT</pubDate>
            <atom:updated>2023-09-27T11:13:52.010Z</atom:updated>
            <content:encoded><![CDATA[<h3>SQL 4 — DML</h3><p>Data Manipulation Language</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*fgcWwcIpix53ZW3gDfBn4A.png" /></figure><p><strong>Creating database</strong><br><em>create database employee_db;</em></p><p><strong>Using database</strong><br><em>use employee_db;</em></p><p><strong>Creating new table</strong><br><em>create table employee(<br> emp_id int primary key,<br> name varchar(15) not null,<br> age int check(age&gt;0 and age&lt;100) not null,<br> gender enum(“m”,”f”,”t”) not null,<br> doj date not null,<br> salary int default 0,<br> skills set(“sql”,”java”,”python”),<br> phone varchar(10) unique not null<br>);</em></p><p><strong>INSERT without column name → provide data for all columns</strong><br><em>insert into employee values(102,”aniket”,29,”m”,”2023–08–12&quot;,25000,”sql,java”,”7896587452&quot;);<br>select * from employee;</em></p><p><strong>INSERT with column name →ignore column in which you dont want to insert data (here skills)</strong><br><em>insert into employee(emp_id,name,age,gender,doj,salary,phone) values(105,”punit”,25,”m”,”2023–07–11&quot;,35000,”7896587451&quot;);<br>select * from employee;</em></p><p><strong>INSERT multiple record at a time</strong><br><em>insert into employee values<br>(110,”rani”,26,”f”,”2023–04–24&quot;,24000,”sql,java”,”7896587412&quot;),<br>(150,”rajat”,35,”m”,”2023–01–12&quot;,45000,”sql”,”7896587457&quot;),<br>(137,”vikas”,31,”m”,”2023–04–10&quot;,35000,”java”,”7896587450&quot;);<br>select * from employee;</em></p><p><strong>INSERT from one table to another</strong><br><em>create table employee_short(<br> emp_id int primary key,<br> name varchar(15) not null,<br> salary int default 0<br>);</em></p><p><em>insert into employee_short select emp_id,name,salary from employee;</em></p><p><em>select * from employee_short;</em></p><p><strong>UPDATE <br>UPDATE one column at a time</strong><br><em>update employee set salary=20000 where emp_id = 102;<br>select * from employee;</em></p><p><strong>UPDATE multiple column at a time</strong><br><em>update employee set age=30, salary=30000 where emp_id=105;<br>select * from employee;</em></p><p><strong>UPDATE without condition (without where)</strong><br><em>update employee set age=35;<br>select * from employee;</em></p><p><em>update employee set age=35,salary=1000;<br>select * from employee;</em></p><p><strong>DELETE <br>Delete one erecord at a time</strong><br><em>delete from employee where emp_id = 102;<br>select * from employee;</em></p><p><strong>Delete multiple records at a time</strong><br><em>delete from employee where gender=”m”;<br>select * from employee;</em></p><p><strong>Delete all record</strong><br><em>delete from employee;<br>select * from employee;</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d969ce6ac92" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL 3 — DDL]]></title>
            <link>https://medium.com/@tejaskasare14/sql-3-ddl-c33164ecb734?source=rss-56007671186f------2</link>
            <guid isPermaLink="false">https://medium.com/p/c33164ecb734</guid>
            <dc:creator><![CDATA[Tejas kasare]]></dc:creator>
            <pubDate>Wed, 27 Sep 2023 10:43:50 GMT</pubDate>
            <atom:updated>2023-09-27T10:43:50.313Z</atom:updated>
            <content:encoded><![CDATA[<h3>SQL 3 — DDL</h3><p>Data Defination language,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*fgcWwcIpix53ZW3gDfBn4A.png" /></figure><p><strong>Create database</strong><br><em>create database employee_db;</em></p><p><strong>Use database</strong><br><em>use employee_db</em>;</p><p><strong>Creating new table “employee” inside employee_db</strong><br><em>create table employee(<br>name varchar(20) not null<br>);</em></p><p><strong>Show tables</strong><br><em>show tables;</em></p><p><strong>Describe table structure</strong><br><em>describe employee;</em></p><p><strong>Add age column in table</strong><br><em>alter table employee add age int not null;</em></p><p><strong>Add phone and gender column in table</strong><br><em>alter table employee add (phone varchar(10), gender enum (“m”, “f”));</em></p><p><strong>Add id at first row of table</strong><br><em>alter table employee add id int primary key first;</em></p><p><strong>Add doj after name column of table</strong><br><em>alter table employee add doj date after name;</em></p><p><strong>Delete column age</strong><br><em>alter table employee drop column age;</em></p><p><strong>Modify phone column data type</strong><br><em>alter table employee modify column phone varchar (30);</em></p><p><strong>Rename phone column into phone number</strong><br><em>alter table emp rename column phone to phone_number;</em></p><p><strong>Rename table</strong><br><em>alter table employee rename to emp;</em></p><p><strong>Add unique constraint on phone_number column</strong><br><em>alter table emp add constraint unique_phone_number unique(phone_number);</em></p><p><strong>Drop Constraint</strong><br><em>alter table emp drop constraint unique_phone_number;</em></p><p><strong>Adding new column “age”</strong><br><em>alter table emp add age int not null;</em></p><p><strong>Adding check constraint on age column</strong><br><em>alter table emp add constraint check_age check(age&gt;0 and age&lt;100);</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c33164ecb734" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL 2 — Constraints]]></title>
            <link>https://medium.com/@tejaskasare14/sql-2-constraints-330e47f0fe97?source=rss-56007671186f------2</link>
            <guid isPermaLink="false">https://medium.com/p/330e47f0fe97</guid>
            <dc:creator><![CDATA[Tejas kasare]]></dc:creator>
            <pubDate>Fri, 08 Sep 2023 15:11:46 GMT</pubDate>
            <atom:updated>2023-09-08T15:11:46.319Z</atom:updated>
            <content:encoded><![CDATA[<h3>SQL 2 — Constraints</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*fgcWwcIpix53ZW3gDfBn4A.png" /></figure><p>In this article we are going to learn about SQL constraints. Constraints means RULES that we are going to apply on column so we can ensures the accuracy and reliability of the data in the table. If there is any violation between the constraint and the data action, the action is aborted. Following constraints are available is SQL —</p><ol><li>Primary Key</li><li>Foreign Key</li><li>Not Null</li><li>Unique</li><li>Check</li><li>Default</li><li>Enum</li><li>Set</li></ol><p>Lets understand above constraints by taking an employee example :</p><p><strong>Create new database</strong> <br><em>create database employee_db;</em></p><p><strong>Selecting database for further operation</strong><br><em>use employee_db;</em></p><p><strong>Create new database inside employee_db</strong><br><em>create table employee(<br> emp_id int primary key,<br> name varchar(15) not null,<br> age int check(age&gt;0 and age&lt;100) not null,<br> gender enum(“m”,”f”,”t”) not null,<br> doj date not null,<br> salary int default 0,<br> skills set(“sql”,”java”,”python”),<br> phone varchar(10) unique not null<br>);</em></p><p><strong>Showing all tables inside employee_db</strong><br><em>show tables;</em></p><p><strong>Checking Structure of employee table</strong><br><em>describe employee;</em></p><p><strong>Inserting right data inside employee table</strong><br><em>insert into employee(emp_id,name,age,gender,doj,salary,skills,phone)<br>values(102,”aniket”,29,”m”,”2023–08–12&quot;,25000,”sql,java”,”7896587452&quot;);</em></p><p><strong>Displaying all data in employee table</strong><br><em>select * from employee;</em></p><blockquote><strong><em>Lets add wrong data into table that violets the constraints. so we can get better understanding of working of constraints</em></strong></blockquote><p><strong>Not passing employee id in the field emp_id</strong><br><em>insert into employee(name,age,gender,doj,salary,skills,phone)<br>values(“aniket”,29,”m”,”2023–08–12&quot;,25000,”sql,java”,”7896587452&quot;);</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*rb8G_kVh4yndMR5L9Wt2Rw.png" /><figcaption>we will get this error because emp_id is PRIMARY KEY, since primary key is by default following NOT NULL constraint, it is expecting some default value, and since we are not having any default value for emp_id, it is giving above error.</figcaption></figure><p><strong>Not passing name</strong><br><em>insert into employee(emp_id,age,gender,doj,salary,skills,phone)<br>values(102,29,”m”,”2023–08–12&quot;,25000,”sql,java”,”7896587452&quot;);</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/1*08opj2wdZ19VDvbKP-IcPw.png" /><figcaption>we will get this error because name is having NOT NULL constraint, it is expecting some default value, and since we are not having any default value for name, it is giving above error.</figcaption></figure><p><strong>Adding wrong age value which is not in given RANGE</strong><br><em>insert into employee(emp_id,name,</em><strong><em>age</em></strong><em>,gender,doj,salary,skills,phone)<br>values(102,”aniket”,</em><strong><em>290</em></strong><em>,”m”,”2023–08–12&quot;,25000,”sql,java”,”7896587452&quot;);</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*TwicHEw6gOy7Wh1nfIFRQw.png" /></figure><p><strong>Adding wrong ENUM — Adding gender other than m, f, t </strong><br><em>insert into employee(emp_id,name,age,</em><strong><em>gender</em></strong><em>,doj,salary,skills,phone)<br>values(102,”aniket”,29,</em><strong><em>”x”,</em></strong><em>”2023–08–12&quot;,25000,”sql,java”,”7896587452&quot;);</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*qbeBDG6qHmwa8Lg7CpkQtQ.png" /></figure><p><strong>Not adding salary</strong><br><em>insert into employee(emp_id,name,age,gender,doj,skills,phone)<br>values(103,”rani”,30,”f”,”2023–08–13&quot;,”sql,java”,”7896587451&quot;);</em></p><p>In above case, data will be inserted in the table even we are not passing the salary value, since we have set default value for salary as zero, Lets check in the table —</p><p><em>select * from employee;</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*6PKVJICjx7-q3DAAJNePaA.png" /></figure><p><strong>Not adding any skills — it will add null</strong><br><em>insert into employee(emp_id,name,age,gender,doj,salary,phone)<br>values(104,”stella”,21,”f”,”2023–08–15&quot;,25000,”7896587412&quot;);</em></p><p>In above case, data will be inserted in the table even we are not passing the skill value. It will insert NULL value because we haven&#39;t set NOT NULL constraint, Lets check in the table —</p><p><em>select * from employee;</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*mxOtCaCyZeHdwRrUafE19w.png" /></figure><p><strong>Adding dupicate phone number</strong><br><em>insert into employee(emp_id,name,age,gender,doj,salary,skills,phone)<br>values(110,”raju”,25,”m”,”2023–08–12&quot;,25000,”sql,java”,”7896587452&quot;);</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*nKE3gxTlCHIdUNLovcG8Qw.png" /><figcaption>Since phone number is duplicate</figcaption></figure><p>THANK YOU</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=330e47f0fe97" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL 1 —  Introduction]]></title>
            <link>https://medium.com/@tejaskasare14/sql-1-introduction-ff8ad903ad0a?source=rss-56007671186f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff8ad903ad0a</guid>
            <dc:creator><![CDATA[Tejas kasare]]></dc:creator>
            <pubDate>Fri, 08 Sep 2023 13:27:20 GMT</pubDate>
            <atom:updated>2023-09-08T13:27:20.835Z</atom:updated>
            <content:encoded><![CDATA[<h3>SQL 1 — Introduction</h3><p>In this article we are going to learn basic SQL statements</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*fgcWwcIpix53ZW3gDfBn4A.png" /></figure><p><strong>To check all databases</strong><br><em>show databases;</em></p><p><strong>To create new database</strong><br><em>create database student_db;</em></p><p><strong>To delete database</strong><br><em>drop database student_db;</em></p><p><strong>To select particular database</strong><br><em>use student_db;</em></p><p><strong>Creating a table inside student_db database</strong><br><em>create table student(id int,name varchar(30) );</em><br> <br><strong>Showing all tables inside selected database(student_db)</strong><br><em>show tables;</em></p><p><strong>Checking structure of newly created table(student)</strong><br><em>describe student;</em></p><p><strong>Adding/inserting data into table</strong><br><em>insert into student(id,name) values(20,”raju”);</em></p><p><strong>Showing all inserted data in table</strong><br><em>select * from student;</em></p><p><strong>Deleting table</strong><br><em>drop table student;</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff8ad903ad0a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to install Java]]></title>
            <link>https://medium.com/@tejaskasare14/spring-rest-project-cbac3432ee78?source=rss-56007671186f------2</link>
            <guid isPermaLink="false">https://medium.com/p/cbac3432ee78</guid>
            <dc:creator><![CDATA[Tejas kasare]]></dc:creator>
            <pubDate>Fri, 16 Jun 2023 06:45:45 GMT</pubDate>
            <atom:updated>2023-06-16T12:59:44.769Z</atom:updated>
            <content:encoded><![CDATA[<h3>check your system has java</h3><p>open cmd and type java</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*zJyuFUg2DXNrmvhyY-laWQ.png" /><figcaption>This indicates java is not installed in your system</figcaption></figure><h3>Install Java</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*4TKB21rV8pD9WBTMSXHE5w.png" /><figcaption>googel downlad java oracle and click on first link</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5trdTlu4BYnApQ4dr9uN4A.png" /><figcaption>download java 17 as it is LTS (select your operating system)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*_TNtD5Uxdx_aLb1kYU6aPg.png" /><figcaption>check dowloads on your browser and double click on it</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*XNuOQDAy2ew_CWjwJhSz4g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*lj866UmCX4Stn2am57v0eg.png" /><figcaption>remember the path because we need it later for adding environmental variables</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*qUgMUwx_Awrr6r8wweMjPw.png" /></figure><h3>Add environmental variables</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*_frm1W6jFxSqMXyCrYsUqQ.png" /><figcaption>Open java installation folder upto bin and copy path</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/358/1*pioumVwyiiCX8iSlQ7EN5Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*sRrDIuETt1ciZprFUwYnuQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*Ub0kb1hZlkcy9w3naju4jg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*P1XuC-DLvbEJGTTHQDsqlg.png" /></figure><h3>Check java is installed</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*QX-L6T8Xdrv7g1HFCHMeZQ.png" /><figcaption>open fresh command promt and type &gt;java -version</figcaption></figure><h3>Install eclipse</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*xzFkbT-f-s43rrMNGKGqiw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Zt2C3i9fvOoIi4DGlAPoA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*gg4zt7_JlUaCnWK-wLVFBg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*eLMkUjNtbnm-citqMnOZnw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*TzTtFI7FSzMp5r4ipwso4Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*Pymt_77hDffa_wBwXeJkXg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*65qJL-IcuwWvrWwtUhKPMA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*gI2TA4bw5YH-rMJfOGb_Cg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*-lOvVYPSakxFhQlDtBIO4A.png" /></figure><h3>Install Spring Tool Suit</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*ZVKcI-vG2U5Mwetm3xqdvQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H32wue9IXPl-lZzUpZJyVA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*30wA1U0ld4eu56Z4UFeU0A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*ZngRV7N8GHYu32qYKjVnYg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*rrpqkh6V0LqN5ef7KW1ErQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*gPguRcdBKB3PlbALIROYqw.png" /><figcaption>if you get error like this. dont worry. run exe file again and you will get sts folder in downloads folder like given below</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*aAhy9_57tEhwmGfy9HzHew.png" /><figcaption>open sts folder and run its exe file</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*-2CcKCHKh_kWvfEP9DI5rg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*4D2scuCXbXpe9AF7e5GC5Q.png" /><figcaption>DONE !</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cbac3432ee78" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring : Mapping and LookUps]]></title>
            <link>https://medium.com/@tejaskasare14/spring-mapping-and-lookups-4f294810b188?source=rss-56007671186f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f294810b188</guid>
            <dc:creator><![CDATA[Tejas kasare]]></dc:creator>
            <pubDate>Sat, 13 May 2023 10:51:35 GMT</pubDate>
            <atom:updated>2023-05-20T12:20:55.887Z</atom:updated>
            <content:encoded><![CDATA[<h3>Spring : Mapping and LookUps</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8R5B_LRuli6JjogWugLV9Q.png" /></figure><h4>Create new Spring project</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*5MBA267IB3Zsa2-fqqPdWQ.png" /></figure><h4>add following dependencies</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*dTxoZ6aoFekAKUN_URICiA.png" /></figure><h4>create following packages</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/319/1*Arnpc2vFAJPSfUOjZ0m8Pg.png" /></figure><h4>create classes and interfaces in above packages</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*Zg3zVc8N6Og7LZcguyrPeg.png" /></figure><p>Create user and database in xampp</p><h3>ONE TO ONE RELATIONSHIP</h3><blockquote>Author.java</blockquote><pre>package com.mapping_lookup.models;<br><br>import java.time.Instant;<br><br>import org.springframework.data.annotation.CreatedDate;<br>import org.springframework.data.annotation.LastModifiedDate;<br>import org.springframework.data.jpa.domain.support.AuditingEntityListener;<br><br>import jakarta.persistence.Column;<br>import jakarta.persistence.Entity;<br>import jakarta.persistence.EntityListeners;<br>import jakarta.persistence.GeneratedValue;<br>import jakarta.persistence.GenerationType;<br>import jakarta.persistence.Id;<br>import jakarta.persistence.JoinColumn;<br>import jakarta.persistence.OneToOne;<br>import jakarta.validation.constraints.Size;<br><br>@Entity<br>@EntityListeners(AuditingEntityListener.class)<br>public class Author {<br><br>  @Id<br>  @GeneratedValue(strategy = GenerationType.AUTO)<br>  private int id;<br>  <br>  @Column(nullable = false)<br>  private String author_name;<br>  <br>  @Column(nullable = false,unique = true)<br>  private String phone;<br><br>  @Column(nullable = false)<br>  private int age;<br>  <br>  @CreatedDate<br>  private Instant createdAt;<br>  <br>  @LastModifiedDate<br>  private Instant updatedAt;<br>  <br>  <br>  // one to one mapping (author to address)<br>  //one author has one address<br>  @OneToOne<br>  @JoinColumn(name=&quot;address_id&quot;)<br>  private Address address;<br>  <br>  <br> public Author() {<br><br> }<br> <br><br> public Author(int id, String author_name, String phone, int age, Instant createdAt, Instant updatedAt,<br>   Address address) {<br>  this.id = id;<br>  this.author_name = author_name;<br>  this.phone = phone;<br>  this.age = age;<br>  this.createdAt = createdAt;<br>  this.updatedAt = updatedAt;<br>  this.address = address;<br> }<br><br><br><br><br> public int getId() {<br>  return id;<br> }<br><br> public String getAuthor_name() {<br>  return author_name;<br> }<br><br> public String getPhone() {<br>  return phone;<br> }<br><br> public int getAge() {<br>  return age;<br> }<br><br> public Instant getCreatedAt() {<br>  return createdAt;<br> }<br><br> public Instant getUpdatedAt() {<br>  return updatedAt;<br> }<br><br> public void setId(int id) {<br>  this.id = id;<br> }<br><br> public void setAuthor_name(String author_name) {<br>  this.author_name = author_name;<br> }<br><br> public void setPhone(String phone) {<br>  this.phone = phone;<br> }<br><br> public void setAge(int age) {<br>  this.age = age;<br> }<br><br> public void setCreatedAt(Instant createdAt) {<br>  this.createdAt = createdAt;<br> }<br><br> public void setUpdatedAt(Instant updatedAt) {<br>  this.updatedAt = updatedAt;<br> }<br><br> public Address getAddress() {<br>  return address;<br> }<br><br> public void setAddress(Address address) {<br>  this.address = address;<br> }<br> <br>}</pre><blockquote>Address.java</blockquote><pre>package com.mapping_lookup.models;<br><br>import java.time.Instant;<br><br>import org.springframework.data.annotation.CreatedDate;<br>import org.springframework.data.annotation.LastModifiedDate;<br>import org.springframework.data.jpa.domain.support.AuditingEntityListener;<br><br>import com.fasterxml.jackson.annotation.JsonIgnore;<br><br>import jakarta.persistence.Column;<br>import jakarta.persistence.Entity;<br>import jakarta.persistence.EntityListeners;<br>import jakarta.persistence.GeneratedValue;<br>import jakarta.persistence.GenerationType;<br>import jakarta.persistence.Id;<br>import jakarta.persistence.OneToOne;<br><br>@Entity<br>@EntityListeners(AuditingEntityListener.class)<br>public class Address {<br><br> @Id<br>  @GeneratedValue(strategy = GenerationType.AUTO)<br>  private int id;<br>  <br>  @Column(nullable = false)<br>  private String city;<br>  <br>  @Column(nullable = false,unique = true)<br>  private String state;<br><br>  @Column(nullable = false)<br>  private int zipcode;<br>  <br>  @CreatedDate<br>  private Instant createdAt;<br>  <br>  @LastModifiedDate<br>  private Instant updatedAt;<br>  <br>  <br>  <br>  <br> //  one to one mapping (author to address)<br>  //one author has one address <br>  @OneToOne(mappedBy = &quot;address&quot;)<br>  @JsonIgnore<br>  private Author author;<br><br><br><br><br> public Address() {<br><br> }<br><br><br><br><br> public Address(int id, String city, String state, int zipcode, Instant createdAt, Instant updatedAt,<br>   Author author) {<br> <br>  this.id = id;<br>  this.city = city;<br>  this.state = state;<br>  this.zipcode = zipcode;<br>  this.createdAt = createdAt;<br>  this.updatedAt = updatedAt;<br>  this.author = author;<br> }<br><br><br><br><br> public int getId() {<br>  return id;<br> }<br><br><br><br><br> public String getCity() {<br>  return city;<br> }<br><br><br><br><br> public String getState() {<br>  return state;<br> }<br><br><br><br><br> public int getZipcode() {<br>  return zipcode;<br> }<br><br><br><br><br> public Instant getCreatedAt() {<br>  return createdAt;<br> }<br><br><br><br><br> public Instant getUpdatedAt() {<br>  return updatedAt;<br> }<br><br><br><br><br> public Author getAuthor() {<br>  return author;<br> }<br><br><br><br><br> public void setId(int id) {<br>  this.id = id;<br> }<br><br><br><br><br> public void setCity(String city) {<br>  this.city = city;<br> }<br><br><br><br><br> public void setState(String state) {<br>  this.state = state;<br> }<br><br><br><br><br> public void setZipcode(int zipcode) {<br>  this.zipcode = zipcode;<br> }<br><br><br><br><br> public void setCreatedAt(Instant createdAt) {<br>  this.createdAt = createdAt;<br> }<br><br><br><br><br> public void setUpdatedAt(Instant updatedAt) {<br>  this.updatedAt = updatedAt;<br> }<br><br><br><br><br> public void setAuthor(Author author) {<br>  this.author = author;<br> }<br>  <br>  <br>  <br>  <br>}</pre><blockquote>AuthorWithoutPhone.java</blockquote><pre>package com.mapping_lookup.projections;<br><br>import java.time.Instant;<br><br>import org.springframework.beans.factory.annotation.Value;<br><br>public interface AuthorWithoutPhone {<br><br> @Value(&quot;#{target.id}&quot;)<br> int getId();<br> <br> @Value(&quot;#{target.author_name}&quot;)<br> String getAuthor_name();<br> <br> @Value(&quot;#{target.age}&quot;)<br> int getAge(); <br> <br> @Value(&quot;#{target.createdAt}&quot;)<br> Instant getCreatedAt();<br> <br> @Value(&quot;#{target.updatedAt}&quot;)<br> Instant getUpdatedAt() ;<br><br> @Value(&quot;#{target.address}&quot;)<br> Address getAddress();<br><br>}</pre><blockquote>AddressRepository.java</blockquote><pre>package com.mapping_lookup.repositories;<br><br>import java.util.List;<br><br>import org.springframework.data.repository.CrudRepository;<br><br>import com.mapping_lookup.models.Address;<br>import com.mapping_lookup.projections.AuthorWithoutPhone;<br><br><br>public interface AddressRepository extends CrudRepository&lt;Address, Integer&gt;{<br><br> <br>}</pre><blockquote>AuthorRepository.java</blockquote><pre>package com.mapping_lookup.repositories;<br><br>import java.util.List;<br><br>import org.springframework.data.repository.CrudRepository;<br><br>import com.mapping_lookup.models.Address;<br>import com.mapping_lookup.models.Author;<br>import com.mapping_lookup.projections.AuthorWithoutPhone;<br><br>public interface AuthorRepository extends CrudRepository&lt;Author, Integer&gt;{<br> List&lt;AuthorWithoutPhone&gt; findAllProjectedBy();<br>}</pre><blockquote>AuthorResponseWrapper.java</blockquote><pre>package com.mapping_lookup.helpers;<br><br>public class AuthorResponseWrapper {<br><br> String message;<br> Object data;<br> public String getMessage() {<br>  return message;<br> }<br> public Object getData() {<br>  return data;<br> }<br> public void setMessage(String message) {<br>  this.message = message;<br> }<br> public void setData(Object data) {<br>  this.data = data;<br> }<br> <br> <br>}</pre><blockquote>AuthorService.java</blockquote><pre>package com.mapping_lookup.services;<br><br>import java.util.List;<br><br>import org.springframework.beans.factory.annotation.Autowired;<br>import org.springframework.stereotype.Service;<br><br>import com.mapping_lookup.models.Address;<br>import com.mapping_lookup.models.Author;<br>import com.mapping_lookup.projections.AuthorWithoutPhone;<br>import com.mapping_lookup.repositories.AddressRepository;<br>import com.mapping_lookup.repositories.AuthorRepository;<br><br>@Service<br>public class AuthorService {<br> @Autowired<br> AuthorRepository authorRepository;<br> <br> @Autowired<br> AddressRepository addressRepository;<br> <br> public Iterable&lt;Author&gt; getAllAuthorWithPhone()<br> {<br>  return authorRepository.findAll();<br> }<br> <br> public List&lt;AuthorWithoutPhone&gt; getAllAuthorWithoutPhone()<br> {<br>  return authorRepository.findAllProjectedBy();<br> }<br> <br> public Author createAuthor(Author author)<br> {<br>  Address got_address=author.getAddress();<br>  Address saved_address=addressRepository.save(got_address);<br>  author.setAddress(saved_address);<br>  return authorRepository.save(author);<br> }<br><br>}</pre><blockquote>AuthorController.java</blockquote><pre>package com.mapping_lookup.controllers;<br><br>import java.util.Iterator;<br><br>import org.springframework.beans.factory.annotation.Autowired;<br>import org.springframework.http.HttpStatus;<br>import org.springframework.http.HttpStatusCode;<br>import org.springframework.http.ResponseEntity;<br>import org.springframework.stereotype.Controller;<br>import org.springframework.web.bind.annotation.GetMapping;<br>import org.springframework.web.bind.annotation.PostMapping;<br>import org.springframework.web.bind.annotation.RequestBody;<br>import org.springframework.web.bind.annotation.RequestMapping;<br>import org.springframework.web.bind.annotation.RestController;<br>import org.springframework.web.server.ResponseStatusException;<br><br>import com.mapping_lookup.helpers.AuthorResponseWrapper;<br>import com.mapping_lookup.models.Author;<br>import com.mapping_lookup.projections.AuthorWithoutPhone;<br>import com.mapping_lookup.repositories.AuthorRepository;<br>import com.mapping_lookup.services.AuthorService;<br><br>@RestController<br>@RequestMapping(&quot;/authors&quot;)<br>public class AuthorController {<br> <br> @Autowired<br> AuthorService authorService;<br> <br> @GetMapping(&quot;&quot;)<br> public ResponseEntity&lt;?&gt; getAllAuthorWithPhone()<br> {<br>  Iterable&lt;Author&gt; data=authorService.getAllAuthorWithPhone();<br>  Iterator all_authors = data.iterator();<br>  if(!all_authors.hasNext())<br>  {<br>   throw new ResponseStatusException(HttpStatus.NOT_FOUND,&quot;No author found&quot;);<br>  }<br>  else<br>  {<br>   AuthorResponseWrapper arr = new AuthorResponseWrapper();<br>   arr.setMessage(&quot;Author found&quot;);<br>   arr.setData(all_authors);<br>   return new ResponseEntity&lt;&gt;(arr,HttpStatus.OK);<br>  }<br> }<br> <br> @GetMapping(&quot;/without-phone&quot;)<br> public ResponseEntity&lt;?&gt; getAllAuthorWithoutPhone()<br> {<br>  Iterable&lt;AuthorWithoutPhone&gt; data=authorService.getAllAuthorWithoutPhone();<br>  Iterator all_authors = data.iterator();<br>  if(!all_authors.hasNext())<br>  {<br>   throw new ResponseStatusException(HttpStatus.NOT_FOUND,&quot;No author found&quot;);<br>  }<br>  else<br>  {<br>   AuthorResponseWrapper arr = new AuthorResponseWrapper();<br>   arr.setMessage(&quot;Author found&quot;);<br>   arr.setData(all_authors);<br>   return new ResponseEntity&lt;&gt;(arr,HttpStatus.OK);<br>  }<br> }<br> <br> @PostMapping(&quot;&quot;)<br> public ResponseEntity&lt;?&gt; createAuthor(@RequestBody Author author)<br> {<br>  <br>  Author createdAuthor=authorService.createAuthor(author);<br>  AuthorResponseWrapper arr = new AuthorResponseWrapper();<br>  arr.setMessage(&quot;Author found&quot;);<br>  arr.setData(createdAuthor);<br>  return new ResponseEntity&lt;&gt;(arr,HttpStatus.CREATED);<br> }<br><br> <br>}</pre><blockquote>add database details in application.properties</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*IusWrpcYAQ8JJ4Zy2x_H8g.png" /></figure><h4>Try to post a record</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*DGNtj5wuz4wBE2eOOTATEw.png" /></figure><h4>check records in the table</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*nTfa32oWp55fpw8goZ10HQ.png" /><figcaption>author table</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*9BhFmh3wykAOTMeDdDVuoA.png" /><figcaption>address table</figcaption></figure><h4>get a record from table</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*Gzq3D0mFYsyTvBHSP3V4Gw.png" /></figure><h4>get a record from table without phone number</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*7JBeEj80j6W56eJWDKHhHg.png" /></figure><h3>ONE TO MANY RELATIONSHIP</h3><p>one author can have multiple bank accounts and only one account belongs to one author</p><blockquote>Create Account.java in models package</blockquote><pre>package com.mapping_lookup.models;<br><br>import org.springframework.data.jpa.domain.support.AuditingEntityListener;<br><br>import com.fasterxml.jackson.annotation.JsonIgnore;<br><br>import jakarta.persistence.Column;<br>import jakarta.persistence.Entity;<br>import jakarta.persistence.EntityListeners;<br>import jakarta.persistence.GeneratedValue;<br>import jakarta.persistence.GenerationType;<br>import jakarta.persistence.Id;<br>import jakarta.persistence.JoinColumn;<br>import jakarta.persistence.ManyToOne;<br><br>@Entity<br>@EntityListeners(AuditingEntityListener.class)<br>public class Account {<br> <br> @Id<br> @GeneratedValue(strategy = GenerationType.AUTO)<br> private int id;<br> <br> @Column(nullable = false,unique = true)<br> private String account_number;<br> <br> <br> @Column()<br> private double balance;<br> <br> <br> @ManyToOne<br> @JoinColumn(name = &quot;author_id&quot;)<br> @JsonIgnore<br> private Author author;<br><br><br> public Account() {<br> }<br><br><br> public Account(int id, String account_number, double balance, Author author) {<br><br>  this.id = id;<br>  this.account_number = account_number;<br>  this.balance = balance;<br>  this.author = author;<br> }<br><br><br> public int getId() {<br>  return id;<br> }<br><br><br> public String getAccount_number() {<br>  return account_number;<br> }<br><br><br> public double getBalance() {<br>  return balance;<br> }<br><br><br> public Author getAuthor() {<br>  return author;<br> }<br><br><br> public void setId(int id) {<br>  this.id = id;<br> }<br><br><br> public void setAccount_number(String account_number) {<br>  this.account_number = account_number;<br> }<br><br><br> public void setBalance(double balance) {<br>  this.balance = balance;<br> }<br><br><br> public void setAuthor(Author author) {<br>  this.author = author;<br> }<br> <br> <br> <br><br>}</pre><blockquote>Create one to many mapping of Account in Authors.java with getters and setters</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*BQvVy_krE_7Q2jE-HRW8Pw.png" /></figure><blockquote>Create Repository for Account as AccountRepository.java in repositories package</blockquote><pre>package com.mapping_lookup.repositories;<br><br>import org.springframework.data.repository.CrudRepository;<br><br>import com.mapping_lookup.models.Account;<br><br>public interface AccountRepository extends CrudRepository&lt;Account, Integer&gt;{<br><br>}</pre><blockquote>In AuthorService.java, create method to add account for specific user</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*BLaz0c0A1g-oJMDFkrdYvw.png" /></figure><blockquote>In AuthorController.java, create post mapping to add account for specific Author</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*qXZgVyEyRsDKifiFxY5Wsg.png" /></figure><p>Lets add account for existing author(author with id 502)</p><p>initially , account array is empty</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*dkgEKQATx7mVcWJbqSqfSQ.png" /></figure><p>inserting account details</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*zHbyQwW-iO0xjXWbSbHoCg.png" /></figure><p>checking in table</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*zYRVpuGg9QeLz__jNDLF8A.png" /></figure><p>getting author deatils (along with account details)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*27Or0qAgfWG4NY3Huy5nGw.png" /></figure><h3>Creating JPA methods for different operations</h3><p>implementing Search functionality (Ex. Find Author By Age)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*z2ds-Ha4ik4WAma-q5MonA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*UM_Co0p9klNOfUHDVLP2zA.png" /></figure><p>testing on postman</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*E1PQEwTHM9mnfheVncRzlw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*hjc1Bjqe-bh4QlJzhEzZ0g.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f294810b188" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring MVC + MySQL]]></title>
            <link>https://medium.com/@tejaskasare14/spring-mvc-mysql-ca692c566b8e?source=rss-56007671186f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca692c566b8e</guid>
            <dc:creator><![CDATA[Tejas kasare]]></dc:creator>
            <pubDate>Tue, 09 May 2023 11:13:08 GMT</pubDate>
            <atom:updated>2023-05-11T11:44:52.537Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8R5B_LRuli6JjogWugLV9Q.png" /></figure><h4>Create user and database in xampp</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*MzBDrtz4-LyrLUSPwvEH0Q.png" /></figure><ul><li>Create user and database with same name</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*cQ9fmaPe3ZaeGJkLjGN7pw.png" /><figcaption>Click on “Go” and you will get database created with user</figcaption></figure><h4>check database</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/219/1*D4X0U6ZTOQOZ0nLNjHhskQ.png" /></figure><h4>Create spring project and add following dependencies</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*Ja2AUafczKrzUHNCIAnuWw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*jPk8p5IyZSykOPwikqwpKA.png" /></figure><h4>Create 3 html files in templates folder</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/245/1*4Ci8QRZPhXpoxXL7Fi5biQ.png" /></figure><h4>Code for HTML files</h4><ul><li>main.html (create fragments here for code reusability)</li></ul><pre>&lt;!doctype html&gt;<br>&lt;html xmlns:th=&quot;https://www.thymeleaf.org/&quot;&gt;<br>  &lt;head th:fragment=&quot;header_fragment&quot;&gt;<br>    &lt;link href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot; integrity=&quot;sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ&quot; crossorigin=&quot;anonymous&quot;&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>  &lt;!-- code for navbar start  --&gt; <br>  &lt;div th:fragment=&quot;navbar_fragment&quot;&gt;<br>    &lt;nav class=&quot;navbar navbar-expand-lg bg-body-tertiary&quot;&gt;<br>     &lt;div class=&quot;container-fluid&quot;&gt;<br>       &lt;a class=&quot;navbar-brand&quot; href=&quot;#&quot;&gt;SPRING MVC PROJECT&lt;/a&gt;<br>       &lt;button class=&quot;navbar-toggler&quot; type=&quot;button&quot; data-bs-toggle=&quot;collapse&quot; data-bs-target=&quot;#navbarSupportedContent&quot; aria-controls=&quot;navbarSupportedContent&quot; aria-expanded=&quot;false&quot; aria-label=&quot;Toggle navigation&quot;&gt;<br>         &lt;span class=&quot;navbar-toggler-icon&quot;&gt;&lt;/span&gt;<br>       &lt;/button&gt;<br>       &lt;div class=&quot;collapse navbar-collapse&quot; id=&quot;navbarSupportedContent&quot;&gt;<br>         &lt;ul class=&quot;navbar-nav me-auto mb-2 mb-lg-0&quot;&gt;<br>           &lt;li class=&quot;nav-item&quot;&gt;<br>             &lt;a class=&quot;nav-link active&quot; aria-current=&quot;page&quot; href=&quot;#&quot;&gt;Home&lt;/a&gt;<br>           &lt;/li&gt;<br>         &lt;/ul&gt;<br>       &lt;/div&gt;<br>     &lt;/div&gt;<br>   &lt;/nav&gt;<br>  &lt;/div&gt;<br> <br>   &lt;script th:fragment=&quot;js_fragment&quot; src=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js&quot; integrity=&quot;sha384-ENjdO4Dr2bkBIFxQpeoTz1HIcje39Wm4jDKdf19U8gI4ddQ3GYNS7NTKfAdVQSZe&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;<br><br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><ul><li>index.html</li></ul><pre>&lt;!DOCTYPE html&gt;<br>&lt;html  xmlns:th=&quot;https://www.thymeleaf.org/&quot;&gt;<br>&lt;head th:include=&quot;main.html :: header_fragment&quot;&gt;<br>&lt;meta charset=&quot;ISO-8859-1&quot;&gt;<br>&lt;title&gt;MVC CRUD&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br> &lt;div th:include=&quot;main.html :: navbar_fragment&quot;&gt;&lt;/div&gt;<br> <br> &lt;div class=&quot;container text-center&quot;&gt;<br>   &lt;a class=&quot;h1 btn btn-primary mt-3 &quot;&gt;Add New Customer&lt;/a&gt;<br> &lt;/div&gt;<br><br> &lt;script th:replace=&quot;main.html :: js_fragment&quot;&gt;&lt;/script&gt;<br><br>&lt;/body&gt;<br>&lt;/html&gt;</pre><h4>Creating controller to display index.html</h4><ul><li>create controllers package along with CustomerController.java class</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/298/1*Fq38FVmC-j_AAlGBRqlUIQ.png" /></figure><ul><li>code for controller</li></ul><pre>package com.mysql_mvc.controllers;<br><br>import org.springframework.stereotype.Controller;<br>import org.springframework.web.bind.annotation.GetMapping;<br>import org.springframework.web.bind.annotation.RequestMapping;<br><br>@Controller<br>public class CustomerController {<br> <br> @GetMapping(&quot;/&quot;)<br> public String index()<br> {<br>  return &quot;index&quot;;<br> }<br><br>}</pre><ul><li>run project and check for output</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fIgKsfq0F9uqHvUPtESSDw.png" /></figure><h4>Handling button click to show add_customer.html</h4><ul><li>add href to button (in index.html)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*8U2BRXY1uyMuTei_9F4DGQ.png" /></figure><ul><li>create get mapping for “add-customer” in controller (CustomerController.java)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*vziwH7OB4f8mKcWNEE_BZA.png" /><figcaption>in above image , at line 10, for get mapping, please add — @ GetMapping(“/”)</figcaption></figure><h4>Table creation and connecting with database</h4><ul><li>add spring data JPA dependecy</li></ul><blockquote>right click on project &gt; Spring &gt; Add Starters</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*gLjX5CoanvpHFEzhjKR_Rw.png" /><figcaption>Search for Spring Data JPA</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*6HUyB5FXnsLuOCaFbh1Ksw.png" /><figcaption>click on arrow to add dependency in pom.xml</figcaption></figure><ul><li>Create model class</li></ul><blockquote>Create models package &gt; Customer.java</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/254/1*MhOYA5Ykr6zhuEVAYtnn7g.png" /></figure><ul><li>code for Customer.java</li></ul><pre>package com.mysql_mvc.models;<br><br>import jakarta.persistence.Column;<br>import jakarta.persistence.Entity;<br>import jakarta.persistence.GeneratedValue;<br>import jakarta.persistence.GenerationType;<br>import jakarta.persistence.Id;<br><br>//@Entity(name = &quot;customer_table&quot;)  used to change table name if you want<br>@Entity<br>public class Customer {<br> @Id  //for primary key<br> @GeneratedValue(strategy = GenerationType.AUTO) // to auto increment primary key<br> int id;<br> <br> //@Column(name=&quot;customer_name&quot;)  used to change column name if you want<br> @Column(nullable = false)<br> String name;<br> <br> @Column(nullable = false,unique = true)<br> String phone;<br><br> public Customer() {<br>  <br> }<br><br> public Customer(int id, String name, String phone) {<br>  this.id = id;<br>  this.name = name;<br>  this.phone = phone;<br> }<br><br> public int getId() {<br>  return id;<br> }<br><br> public void setId(int id) {<br>  this.id = id;<br> }<br><br> public String getName() {<br>  return name;<br> }<br><br> public void setName(String name) {<br>  this.name = name;<br> }<br><br> public String getPhone() {<br>  return phone;<br> }<br><br> public void setPhone(String phone) {<br>  this.phone = phone;<br> }<br> <br>}</pre><ul><li>setting credentials in application.properties to use MYSQL database</li></ul><pre>spring.datasource.url=jdbc:mysql://localhost:3307/customer_db<br>spring.datasource.username=customer_db<br>spring.datasource.password=customer@123<br>spring.jpa.hibernate.ddl-auto=update</pre><ul><li>Restart a server and check for table created inside customer_db database</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/179/1*iaemCYvI_Zy0__BpChm9dw.png" /></figure><h4>INSERT operation</h4><ul><li>while displaying form, send customer object to bind data with input tags. so changes in get mapping of displaying add customer template</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*UqJarVMRbHVAC9eBpmseCQ.png" /></figure><ul><li>code for add_customer.html to display form</li></ul><pre>&lt;!DOCTYPE html&gt;<br>&lt;html  xmlns:th=&quot;https://www.thymeleaf.org/&quot;&gt;<br>&lt;head th:include=&quot;main.html :: header_fragment&quot;&gt;<br>&lt;meta charset=&quot;ISO-8859-1&quot;&gt;<br>&lt;title&gt;MVC CRUD&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br> &lt;div th:include=&quot;main.html :: navbar_fragment&quot;&gt;&lt;/div&gt;<br> <br> &lt;div class=&quot;container text-center&quot;&gt;<br>   &lt;h1&gt;Add Customer&lt;/h1&gt;<br> &lt;/div&gt;<br> <br> &lt;!-- Form code --&gt;<br> &lt;div class=&quot;container&quot;&gt;<br>   &lt;form class=&quot;col-6&quot; th:object=&quot;${customer_object}&quot; method=&quot;post&quot; th:action=&quot;@{/add-customer}&quot;&gt;<br>     &lt;div class=&quot;mb-3&quot;&gt;<br>       &lt;label for=&quot;customer_name&quot; class=&quot;form-label&quot;&gt;Name :&lt;/label&gt;<br>       &lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;customer_name&quot; th:field=&quot;*{name}&quot;&gt;<br>     &lt;/div&gt;<br>     &lt;div class=&quot;mb-3&quot;&gt;<br>       &lt;label for=&quot;customer_phone&quot; class=&quot;form-label&quot;&gt;Phone :&lt;/label&gt;<br>       &lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;customer_phone&quot; th:field=&quot;*{phone}&quot;&gt;<br>     &lt;/div&gt;<br>     &lt;button type=&quot;submit&quot; class=&quot;btn btn-primary&quot;&gt;Submit&lt;/button&gt;<br>   &lt;/form&gt;<br> &lt;/div&gt;<br><br> &lt;script th:replace=&quot;main.html :: js_fragment&quot;&gt;&lt;/script&gt;<br><br>&lt;/body&gt;<br>&lt;/html&gt;</pre><ul><li>create post mapping to submit form</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*rKQ9UyiTRbBaRc2QTs1GDQ.png" /></figure><ul><li>create “repositories” package &gt; create CustomerRepository interface</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/269/1*wpGG0sK_kMOVuERWyMkAVg.png" /></figure><ul><li>code for CustomerRepository</li></ul><pre>package com.mysql_mvc.repositories;<br><br>import org.springframework.data.repository.CrudRepository;<br><br>import com.mysql_mvc.models.Customer;<br><br>public interface CustomerRepository extends CrudRepository&lt;Customer, Integer&gt;<br>{<br>}</pre><ul><li>inject repository in Controller using @AutoWired</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*cJZcvETiTzuBf4b--ieIXA.png" /></figure><ul><li>use this repository to add/insert data into table (in post mapping)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*37vlrVmsvXneHY0m-6g7vw.png" /></figure><ul><li>restart project and add some data</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*SQgq7SGcoSeihqdag-JqbA.png" /></figure><ul><li>check in the table</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*D1171bfUrd9-prwN5gE1Rw.png" /><figcaption>add 4–5 more records</figcaption></figure><h4>INSERT DONE</h4><h4>SELECT Operation : select all records and display in index.html in table</h4><ul><li>fetch data from table and send it to index.html (just update GetMapping(“/”) and fetch data using findAll() method of repository)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*tvzfBagw1mYB4CVpds6FNA.png" /></figure><ul><li>display data in index.html using th:each (for each loop of thymleaf)</li></ul><pre>&lt;!DOCTYPE html&gt;<br>&lt;html  xmlns:th=&quot;https://www.thymeleaf.org/&quot;&gt;<br>&lt;head th:include=&quot;main.html :: header_fragment&quot;&gt;<br>&lt;meta charset=&quot;ISO-8859-1&quot;&gt;<br>&lt;title&gt;MVC CRUD&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br> &lt;div th:include=&quot;main.html :: navbar_fragment&quot;&gt;&lt;/div&gt;<br> <br> &lt;div class=&quot;container text-center&quot;&gt;<br>   &lt;a class=&quot;h1 btn btn-primary mt-3&quot; th:href=&quot;@{/add-customer}&quot;&gt;Add New Customer&lt;/a&gt;<br>   &lt;table class=&quot;table mt-3 table-bordered&quot;&gt;<br>     &lt;thead&gt;<br>       &lt;tr class=&quot;h4&quot;&gt;<br>         &lt;th&gt;ID&lt;/th&gt;<br>         &lt;th&gt;NAME&lt;/th&gt;<br>         &lt;th&gt;PHONE&lt;/th&gt;<br>         &lt;th colspan=&quot;2&quot;&gt;OPERATION&lt;/th&gt;<br>       &lt;/tr&gt;<br>     &lt;/thead&gt;<br>     &lt;tbody&gt;<br>       &lt;tr class=&quot;h5&quot; th:each=&quot;customer: ${all_customers}&quot;&gt;<br>        &lt;td th:text=&quot;${customer.id}&quot; /&gt;<br>        &lt;td th:text=&quot;${customer.name}&quot; /&gt;<br>        &lt;td th:text=&quot;${customer.phone}&quot; /&gt;<br>        &lt;td&gt; &lt;a class=&quot;btn btn-warning mt-3&quot; th:href=&quot;@{/}&quot;&gt;Edit&lt;/a&gt; &lt;/td&gt;<br>        &lt;td&gt; &lt;a class=&quot;btn btn-danger mt-3&quot; th:href=&quot;@{/}&quot;&gt;Delete&lt;/a&gt; &lt;/td&gt;<br>    &lt;/tr&gt;   <br>     &lt;/tbody&gt;<br>  &lt;/table&gt;<br> &lt;/div&gt;<br><br> &lt;script th:replace=&quot;main.html :: js_fragment&quot;&gt;&lt;/script&gt;<br><br>&lt;/body&gt;<br>&lt;/html&gt;</pre><ul><li>data in customer table</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*DxZ3ObfqUfnEbk9jc9UFQg.png" /></figure><ul><li>data in output</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b_OYKd6If0vgaWh2HdXLPw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca692c566b8e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring : Working with Lombok]]></title>
            <link>https://medium.com/@tejaskasare14/spring-working-with-lombok-80e03726b343?source=rss-56007671186f------2</link>
            <guid isPermaLink="false">https://medium.com/p/80e03726b343</guid>
            <dc:creator><![CDATA[Tejas kasare]]></dc:creator>
            <pubDate>Thu, 04 May 2023 14:32:42 GMT</pubDate>
            <atom:updated>2023-05-08T14:49:17.534Z</atom:updated>
            <content:encoded><![CDATA[<h3>Spring : Working with Lombok</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8R5B_LRuli6JjogWugLV9Q.png" /></figure><h4>Create Project</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*BoW1L_AxCsIi5PYwnbRoDg.png" /></figure><h4>Add following dependencies</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*Slyd3bEewoUYbNDg4xGQbw.png" /></figure><h4>Create “models” package with 3 models class</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*_6SXv4JPW4KWvz0SZwC92A.png" /></figure><blockquote>While creating models, we don’t have to specify constructor, getters or setters. All of this taken care by @Data annotation (from Lombok package)</blockquote><ul><li>Account.java</li></ul><pre>package com.rest_lombok.models;<br><br>import java.time.Instant;<br><br>import org.springframework.data.annotation.CreatedDate;<br>import org.springframework.data.annotation.LastModifiedDate;<br>import org.springframework.data.jpa.domain.support.AuditingEntityListener;<br><br>import com.fasterxml.jackson.annotation.JsonIgnore;<br><br>import jakarta.persistence.Column;<br>import jakarta.persistence.Entity;<br>import jakarta.persistence.EntityListeners;<br>import jakarta.persistence.GeneratedValue;<br>import jakarta.persistence.GenerationType;<br>import jakarta.persistence.Id;<br>import jakarta.persistence.JoinColumn;<br>import jakarta.persistence.ManyToOne;<br>import lombok.Data;<br><br>@Entity<br>@EntityListeners(AuditingEntityListener.class)<br>@Data<br>public class Account {<br> @Id<br> @GeneratedValue(strategy = GenerationType.AUTO)<br> private int id;<br> <br> @Column(nullable = false)<br> private int account_number;<br> <br> @Column(nullable = false)<br> private int balance;<br> <br> @ManyToOne<br> @JoinColumn(name=&quot;employee_id&quot;)<br> private Employee employee;<br><br> @CreatedDate<br> private Instant createdAt;<br> <br> @LastModifiedDate<br> private Instant updatedAt;<br>}</pre><ul><li>Address.java</li></ul><pre>package com.rest_lombok.models;<br><br>import java.time.Instant;<br><br>import org.springframework.data.annotation.CreatedDate;<br>import org.springframework.data.annotation.LastModifiedDate;<br>import org.springframework.data.jpa.domain.support.AuditingEntityListener;<br><br>import com.fasterxml.jackson.annotation.JsonIgnore;<br>import com.fasterxml.jackson.annotation.JsonIgnoreProperties;<br><br>import jakarta.persistence.Column;<br>import jakarta.persistence.Entity;<br>import jakarta.persistence.EntityListeners;<br>import jakarta.persistence.GeneratedValue;<br>import jakarta.persistence.GenerationType;<br>import jakarta.persistence.Id;<br>import jakarta.persistence.OneToOne;<br>import lombok.Data;<br><br>@Entity<br>@EntityListeners(AuditingEntityListener.class)<br>@Data<br>public class Address {<br> @Id<br> @GeneratedValue(strategy = GenerationType.AUTO)<br> private int id;<br> <br> @Column(nullable = false)<br> private String state;<br> <br> @Column(nullable = false)<br> private String zipCode;<br> <br> @OneToOne(mappedBy = &quot;address&quot;)<br> private Employee employee;<br> <br> @CreatedDate<br> private Instant createdAt;<br> <br> @LastModifiedDate<br> private Instant updatedAt;<br><br>}</pre><ul><li>Employee.java</li></ul><pre>package com.rest_lombok.models;<br><br>import java.time.Instant;<br>import java.util.List;<br><br>import org.springframework.data.annotation.CreatedDate;<br>import org.springframework.data.annotation.LastModifiedDate;<br>import org.springframework.data.jpa.domain.support.AuditingEntityListener;<br><br>import jakarta.persistence.Column;<br>import jakarta.persistence.Entity;<br>import jakarta.persistence.EntityListeners;<br>import jakarta.persistence.GeneratedValue;<br>import jakarta.persistence.GenerationType;<br>import jakarta.persistence.Id;<br>import jakarta.persistence.JoinColumn;<br>import jakarta.persistence.OneToMany;<br>import jakarta.persistence.OneToOne;<br>import jakarta.validation.constraints.Max;<br>import jakarta.validation.constraints.Min;<br>import jakarta.validation.constraints.NotNull;<br>import jakarta.validation.constraints.Size;<br>import lombok.Data;<br><br>@Entity<br>@EntityListeners(AuditingEntityListener.class)<br>@Data<br>public class Employee {<br><br> @Id<br> @GeneratedValue(strategy = GenerationType.AUTO)<br> private int id;<br> <br> @Size(min = 3,max=30,message = &quot;name must be between 3 to 30 charachters&quot;)<br> @NotNull(message = &quot;name cant be null&quot;)<br> @Column(nullable = false,unique = false)<br> private String name;<br> <br> @Size(min = 3,max=15,message = &quot;city must be between 3 to 15 charachters&quot;)<br> @NotNull(message = &quot;city cant be null&quot;)<br> @Column(nullable = false,unique = false)<br> private String city;<br> <br> @Size(min = 3,max=15,message = &quot;password must be between 3 to 15 charachters&quot;)<br> @NotNull(message = &quot;password cant be null&quot;)<br> @Column(nullable = false,unique = true)<br> private String password;<br> <br> @Min(value = 0,message = &quot;salary cant be zero or minus&quot;)<br> @Max(value = 500000,message = &quot;max salary 500000&quot;)<br> @NotNull(message = &quot;salary cant be null&quot;)<br> @Column(nullable = true)<br> private int salary;<br> <br> @NotNull(message = &quot;gender cant be null&quot;)<br> @Column(nullable = false)<br> private char gender;<br> <br> @OneToOne<br> @JoinColumn(name = &quot;address_id&quot;)<br> private Address address;<br> <br> @OneToMany(mappedBy = &quot;employee&quot;)<br> private List&lt;Account&gt; account;<br> <br> @CreatedDate<br> private Instant createdAt;<br> <br> @LastModifiedDate<br> private Instant updatedAt;<br><br>}</pre><h4>Create “repositories” package and create 3 interfaces (repositories) in it</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*36LWbv4gAN11NmG1sOaa3A.png" /></figure><ul><li>code for repositories</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*TzjTpX4xOS9P47WNF2tEdw.png" /></figure><h4>Add @EnableJpaAuditing on main class</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/1*7NmsGd1WbxU5jXipCcfxNQ.png" /></figure><h4>Add database related properties in application.properties</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*rNxZape59pLBKEYpDNrtfA.png" /><figcaption>in this project I&#39;m reusing my previous database —</figcaption></figure><h4>Open xampp and start Mysql and Apache</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*-ApS2k1YqrR8jByPswmMMg.png" /></figure><h4>Run the Project</h4><h4>Open Postman and check get API</h4><ul><li>check base url</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*N6vVVuSl1haCiaLEYDKTRw.png" /><figcaption>automatic API generation because of <strong>Rest Repository</strong> dependency (added in step 2 above)</figcaption></figure><ul><li>data available in database</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*_ZqtpyTH7QDh2yVNFEgalQ.png" /><figcaption>employee table</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/369/1*4XSDAz_riBwtwyZ-zx90mw.png" /><figcaption>address table</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/1*XcklK8TQKDdPrSMF5F_aNQ.png" /><figcaption>account table</figcaption></figure><ul><li>getting all employees</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*xbkX2C9K-FTWCn7S8A3ShA.png" /><figcaption><strong>Image1</strong></figcaption></figure><ul><li>getting details of employee with id 602 (from Image1)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*J5KbOp73kyyIOl1_A5625A.png" /></figure><ul><li>getting account details of employee with id 602 (from Image1)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*iKCT9dPF9l2hflZJ8-524w.png" /></figure><ul><li>getting address details of employee with id 602 (from above Image1)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*5X37NEi-wGEGtJRx_fGjMQ.png" /></figure><h4>Open Postman and check post API</h4><blockquote>add new employee</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*pFGzXsA1mdgmWTGFGxKxBQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*spjLLrJe1akzylD3ldvK4g.png" /></figure><blockquote>add new address</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*Iww8KY_9_7bXUgfWKocyyA.png" /><figcaption>posting/adding new address from postman</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*IKgwzt9bkADTA2ZnPQh3jg.png" /><figcaption>same data added in table</figcaption></figure><ul><li>in above image you can see, id of newly added address is 152, lets add this address for newly added user (id 704) <strong>(ONE to ONE relationship)</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*MKJPtZJuEtHCDGvAku9S8A.png" /><figcaption>text/uri-list</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*coAa-lquXishmuaprJivJA.png" /></figure><blockquote>Adding new account details</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*wiuqulNNbbl87CcVc3aLSQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*YScpqovpuU7r0VDPBX-WNQ.png" /></figure><ul><li>in above image you can see, id of newly added account is 102, lets add this account for newly added user (id 704) <strong>(ONE to MANY relationship)</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*IKmCOunGC7FBrHwBmjigAQ.png" /><figcaption>there is no any account associated with employee 704</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*c1jk2CXE6ET0BSSY6Zp1Uw.png" /><figcaption>adding newly created account(102) to newly created employee (704). In headers add -&gt; content-type = text/uri-list</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*moF4D6RlWF4RJhLQEAIzfw.png" /><figcaption>account 102 got associated with employee 704</figcaption></figure><h4>Many to Many relationship</h4><p>lets understand this by : multiple employees can work on single project or multiple projects can be done by one employee</p><ul><li>create Project model — Project.java in models package</li></ul><pre>package com.rest_lombok.models;<br><br>import java.time.Instant;<br>import java.util.List;<br><br>import org.springframework.data.annotation.CreatedDate;<br>import org.springframework.data.annotation.LastModifiedBy;<br>import org.springframework.data.annotation.LastModifiedDate;<br>import org.springframework.data.jpa.domain.support.AuditingEntityListener;<br><br>import jakarta.persistence.Column;<br>import jakarta.persistence.Entity;<br>import jakarta.persistence.EntityListeners;<br>import jakarta.persistence.GeneratedValue;<br>import jakarta.persistence.GenerationType;<br>import jakarta.persistence.Id;<br>import jakarta.persistence.ManyToMany;<br>import lombok.Data;<br><br>@Entity<br>@Data<br>@EntityListeners(AuditingEntityListener.class)<br>public class Project {<br> @Id<br> @GeneratedValue(strategy = GenerationType.AUTO)<br> int id;<br> <br> @Column(nullable = false, unique = true)<br> String project_name;<br> <br> @Column(nullable = false)<br> String technoloy;<br> <br> @ManyToMany(mappedBy = &quot;project&quot;)<br> private List&lt;Employee&gt; employee;<br> <br> @CreatedDate<br> Instant createdAt;<br> <br> @LastModifiedDate<br> Instant updatedAt;<br><br>}</pre><ul><li>make many to many reference in Employee model (Employee.java)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*B3PD7yIoSXEe2HEvoxM7Hw.png" /></figure><ul><li>create repository for Project</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*T-oAIPtkw6f0VlLncwJieg.png" /></figure><pre>package com.rest_lombok.repositories;<br><br>import org.springframework.data.repository.CrudRepository;<br><br>import com.rest_lombok.models.Project;<br><br>public interface ProjectRepository extends CrudRepository&lt;Project, Integer&gt;{<br><br>}</pre><ul><li>start/restart project and you will get employee_project table</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/192/1*Rnn_fexJAzbPBaX3HJSeTg.png" /></figure><p>Checking on Postman</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*B47TOdklZ8bjvbulgeGjow.png" /></figure><ul><li>add some projects through postman</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*4KY4ieeMSQD6gbNDTYVZTg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*J-9001Svz626_-eJ7s0ZDQ.png" /></figure><ul><li>getting all projects</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*0GODgxP1ng11HW8ZdTgY5A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/1*QzUcLKqIb7qXW0T6B6GXmw.png" /></figure><ul><li>adding multiple projects to single employee</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*F7l_VgboG8zJahIUbqD4Og.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*UM9jvliuamxoIZpleBXyog.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*cnS1whdFPpQBtO-JXSO0Zw.png" /></figure><ul><li>getting all projects assigned to employee 602</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*Y4ND_VfiENxfT8uEDu17vw.png" /></figure><ul><li>adding multiple employees to single project</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80e03726b343" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>