diff --git a/projekt_2/.idea/.gitignore b/projekt_2/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/projekt_2/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/projekt_2/.idea/aws.xml b/projekt_2/.idea/aws.xml new file mode 100644 index 0000000..2c4ea32 --- /dev/null +++ b/projekt_2/.idea/aws.xml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/projekt_2/.idea/compiler.xml b/projekt_2/.idea/compiler.xml new file mode 100644 index 0000000..52fc528 --- /dev/null +++ b/projekt_2/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/projekt_2/.idea/encodings.xml b/projekt_2/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/projekt_2/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/projekt_2/.idea/inspectionProfiles/Project_Default.xml b/projekt_2/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..28785c4 --- /dev/null +++ b/projekt_2/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,67 @@ + + + + \ No newline at end of file diff --git a/projekt_2/.idea/jarRepositories.xml b/projekt_2/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/projekt_2/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/projekt_2/.idea/misc.xml b/projekt_2/.idea/misc.xml new file mode 100644 index 0000000..ecfa09c --- /dev/null +++ b/projekt_2/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/projekt_2/.idea/modules.xml b/projekt_2/.idea/modules.xml new file mode 100644 index 0000000..5d5fe20 --- /dev/null +++ b/projekt_2/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/projekt_2/.idea/vcs.xml b/projekt_2/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/projekt_2/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/projekt_2/README.md b/projekt_2/README.md new file mode 100644 index 0000000..e21b689 --- /dev/null +++ b/projekt_2/README.md @@ -0,0 +1 @@ +# Projekt 2 diff --git a/projekt_2/docker-compose.yml b/projekt_2/docker-compose.yml new file mode 100644 index 0000000..3a4070c --- /dev/null +++ b/projekt_2/docker-compose.yml @@ -0,0 +1,23 @@ +version: "3.9" + +services: + db: + image: postgres:15-alpine + volumes: + - dev-db-data:/var/lib/postgresql/data + container_name: pra-db + environment: + - POSTGRES_DB=pra_db + - POSTGRES_USER=devuser + - POSTGRES_PASSWORD=admin + ports: + - "5432:5432" + healthcheck: + test: [ "CMD-SHELL", "pg_isready -U devuser -d pra_db" ] + interval: 10s + timeout: 5s + retries: 5 + + +volumes: + dev-db-data: \ No newline at end of file diff --git a/projekt_2/init_db.sql b/projekt_2/init_db.sql new file mode 100644 index 0000000..15ea99c --- /dev/null +++ b/projekt_2/init_db.sql @@ -0,0 +1,600 @@ +-- BOOKS +CREATE TABLE IF NOT EXISTS books ( + id SERIAL PRIMARY KEY, + title VARCHAR(255) NOT NULL +); + +INSERT INTO books (title) VALUES +('The Great Gatsby'), +('To Kill a Mockingbird'), +('1984'), +('Pride and Prejudice'), +('The Catcher in the Rye'), +('Moby-Dick'), +('War and Peace'), +('Great Expectations'), +('Ulysses'), +('The Odyssey'), +('Madame Bovary'), +('Jane Eyre'), +('Crime and Punishment'), +('Wuthering Heights'), +('The Adventures of Huckleberry Finn'), +('Lolita'), +('Anna Karenina'), +('Brave New World'), +('Don Quixote'), +('The Brothers Karamazov'), +('One Hundred Years of Solitude'), +('The Iliad'), +('The Grapes of Wrath'), +('In Search of Lost Time'), +('Fahrenheit 451'), +('Hamlet'), +('Macbeth'), +('A Tale of Two Cities'), +('The Picture of Dorian Gray'), +('Dracula'), +('The Hobbit'), +('Heart of Darkness'), +('The Sound and the Fury'), +('Catch-22'), +('The Stranger'); + +-- AUTHORS +CREATE TABLE IF NOT EXISTS authors ( + author_id SERIAL PRIMARY KEY, + name VARCHAR(255) NOT NULL +); + +INSERT INTO authors (name) VALUES +('F. Scott Fitzgerald'), +('Harper Lee'), +('George Orwell'), +('Jane Austen'), +('J.D. Salinger'), +('Herman Melville'), +('Leo Tolstoy'), +('Charles Dickens'), +('James Joyce'), +('Homer'), +('Gustave Flaubert'), +('Charlotte Brontë'), +('Fyodor Dostoevsky'), +('Emily Brontë'), +('Mark Twain'), +('Vladimir Nabokov'), +('Leo Tolstoy'), +('Aldous Huxley'), +('Miguel de Cervantes'), +('Fyodor Dostoevsky'), +('Gabriel García Márquez'), +('Homer'), +('John Steinbeck'), +('Marcel Proust'), +('Ray Bradbury'), +('William Shakespeare'), +('William Shakespeare'), +('Charles Dickens'), +('Oscar Wilde'), +('Bram Stoker'), +('J.R.R. Tolkien'), +('Joseph Conrad'), +('William Faulkner'), +('Joseph Heller'), +('Albert Camus'); + +-- BOOK DETAILS +CREATE TABLE IF NOT EXISTS book_details ( + details_id SERIAL PRIMARY KEY, + page_count INT, + isbn VARCHAR(255), + book_id BIGINT, + author_id BIGINT, + FOREIGN KEY (book_id) REFERENCES books(id), + FOREIGN KEY (author_id) REFERENCES authors(author_id) +); + +INSERT INTO book_details (page_count, isbn, book_id, author_id) VALUES +(180, '978-0141182636', 1, 1), +(281, '978-0060935467', 2, 2), +(328, '978-0451524935', 3, 3), +(279, '978-0141439518', 4, 4), +(214, '978-0316769488', 5, 5), +(378, '978-1503280786', 6, 6), +(1296, '978-1853260629', 7, 7), +(544, '978-0141439563', 8, 8), +(730, '978-0199535675', 9, 9), +(555, '978-0140268867', 10, 10), +(444, '978-0260268867', 11, 11), +(333, '978-0210268867', 12, 12), +(500, '978-091218867', 13, 13), +(522, '978-0240261867', 14, 14), +(366, '978-0230268867', 15, 15), +(500, '978-0140268867', 16, 16), +(320, '978-0141182667', 17, 17), +(268, '978-0060850524', 18, 18), +(976, '978-0060934347', 19, 19), +(824, '978-0374528379', 20, 20), +(417, '978-0060883287', 21, 21), +(752, '978-0140275360', 22, 22), +(464, '978-0143039433', 23, 23), +(4210, '978-0553213119', 24, 24), +(158, '978-1451673319', 25, 25), +(300, '978-0451526922', 26, 26), +(288, '978-0451526779', 27, 27), +(544, '978-0141439600', 28, 28), +(176, '978-0486278070', 29, 29), +(418, '978-0486411095', 30, 30), +(310, '978-0547928227', 31, 31), +(144, '978-0486264646', 32, 32), +(320, '978-0679732242', 33, 33), +(453, '978-1451626650', 34, 34), +(123, '978-0679720201', 35, 35); + +-- REVIEWS +CREATE TABLE IF NOT EXISTS reviews ( + review_id SERIAL PRIMARY KEY, + book_id BIGINT, + rating INT, + review_text TEXT, + author_name VARCHAR(100), + FOREIGN KEY (book_id) REFERENCES books(id) +); + +INSERT INTO reviews(book_id, rating, review_text, author_name) VALUES +(1, 1, 'Matter car serve order risk number.', 'Thomas Medina'), +(1, 8, 'Which dream cold in white.', 'Donald Murphy'), +(1, 5, 'Green public say trouble avoid religious glass avoid sure.', 'Steven Reid'), +(1, 2, 'Personal true anything least include than poor oil debate.', 'Brian Martin'), +(1, 3, 'Level hospital believe production blood capital window line system beyond sea.', 'Erin Harrington'), +(1, 10, 'Someone wind several rest particular.', 'Kenneth Bryant'), +(1, 6, 'Price sit message as music create parent.', 'Jennifer Lam'), +(1, 3, 'Day only wind possible.', 'Levi Hardin'), +(1, 9, 'Choose grow music full.', 'Beth Wiggins'), +(1, 10, 'Remain affect yes deep station method.', 'Ashley Wiley'), +(1, 6, 'Manage turn early reduce.', 'Nicholas Brown'), +(1, 9, 'Raise scientist indeed often some maybe child reduce six turn officer upon.', 'Christy Johnston'), +(1, 7, 'Consumer may around table matter offer result consider.', 'Kayla Hawkins'), +(2, 8, 'Although line can final.', 'Charles Kim'), +(2, 2, 'Road present our rather director.', 'Rachel Morgan'), +(2, 8, 'Point look perhaps camera wear agent inside.', 'Justin Sawyer'), +(2, 3, 'Magazine hot memory improve.', 'Ronald Gomez'), +(2, 2, 'Country yes management wonder dinner director along material.', 'Amanda Snow'), +(2, 6, 'Source method look reach along professional generation daughter main finish store citizen.', 'Michael Brown'), +(2, 2, 'Response majority safe relationship increase national big argue yourself better worker.', 'Brittany Davis'), +(2, 1, 'Gas question different market.', 'Mary Turner'), +(2, 8, 'Whole eye exactly say quality.', 'Roberta West'), +(2, 3, 'Girl new hold.', 'David Wagner'), +(2, 4, 'Rather of back across without.', 'Alexander Bass'), +(2, 9, 'Population reflect leader big explain ok.', 'Robert Sullivan'), +(2, 4, 'Summer fund letter factor financial yourself outside whether continue.', 'Christopher Krueger'), +(3, 1, 'Offer yes stuff sell own option quality.', 'Thomas Rodriguez'), +(3, 6, 'Else college show consumer land.', 'Jessica Page'), +(3, 3, 'Know quickly image best movie only.', 'Pamela Poole'), +(3, 4, 'Person play second.', 'Christopher Davis'), +(3, 10, 'Build effect thing help wind.', 'Janet Arellano'), +(3, 1, 'Probably yard stay television federal interesting democratic any call one.', 'Daniel Green'), +(3, 4, 'Attention require area identify detail policy.', 'Trevor Ferguson'), +(3, 2, 'Prove exactly property might pay organization quickly little nature.', 'Bonnie Moreno'), +(3, 1, 'Yet meeting food begin heart deal current method.', 'James Turner'), +(3, 9, 'Us standard rock student fall.', 'Mark Smith'), +(3, 10, 'Now experience pick thus day suffer.', 'Colleen Santiago'), +(3, 8, 'Special stage himself particularly between lot water service.', 'Brenda Johnson'), +(3, 3, 'Machine six too real lose.', 'Diane Cooper'), +(4, 2, 'Nation class human five beautiful product mean town out.', 'Susan Alvarez'), +(4, 5, 'Sense very box military sport cover director investment discuss.', 'Christopher Campbell'), +(4, 2, 'Tough write professor other sister assume owner mission control.', 'Wendy Owens'), +(4, 1, 'Worker image likely war.', 'Vanessa Davis'), +(4, 8, 'Right seven heart risk common happen.', 'Joshua Smith'), +(4, 3, 'Yet range position.', 'Kiara Rodriguez'), +(4, 10, 'Large single ago author talk.', 'Nicholas Davis'), +(4, 7, 'Current world both shoulder serious.', 'Kathryn Smith'), +(4, 8, 'Page available use enter home away usually several also play world system.', 'Jasmine Jennings'), +(4, 9, 'Forward major world draw population population him method write talk.', 'Joshua Hampton'), +(4, 5, 'Although player rest language yet factor kitchen his.', 'Lisa Spencer'), +(4, 2, 'Whom behavior as car family during office today different debate.', 'Jessica Keith'), +(4, 4, 'Theory artist success front.', 'Amy Mason'), +(5, 3, 'The often much direction learn heart factor.', 'Kaitlyn Johnson'), +(5, 6, 'Light around manager city within movie message.', 'Tyler Riddle'), +(5, 10, 'Star onto season himself.', 'Wendy Rollins'), +(5, 6, 'Us economy per.', 'Mary Baker'), +(5, 6, 'Alone story fire million.', 'Deborah Webster'), +(5, 5, 'Common themselves herself already history house decide.', 'Jason Smith'), +(5, 4, 'Rock company still measure author able full.', 'Charles Kennedy'), +(5, 4, 'Learn pressure pretty great throw nothing.', 'Alexandra Russell'), +(5, 4, 'Agree staff party Republican.', 'Heather Jensen'), +(5, 10, 'Home pattern by around why world yard peace cultural red chance.', 'Lauren Smith'), +(5, 4, 'Religious government someone including involve pressure color.', 'Melanie Huang'), +(5, 2, 'Trade catch expert she race.', 'Jordan Mitchell'), +(5, 1, 'Relationship seat serve take change important woman.', 'Susan Taylor'), +(6, 6, 'Those child federal four actually collection.', 'Christine Morris'), +(6, 4, 'Human full thank officer maybe least sure dream character.', 'Sharon Schultz'), +(6, 5, 'Clearly because throughout race area beyond seek.', 'Dale Carr'), +(6, 10, 'Garden anything especially kind.', 'Richard Evans'), +(6, 6, 'Wife main suffer half responsibility.', 'Kirsten Scott'), +(6, 6, 'Difference wrong where picture would best position respond buy Democrat.', 'Tina Vega'), +(6, 4, 'Purpose range true choice fly join.', 'Sandra Phillips'), +(6, 9, 'Much report easy short project.', 'Sharon Sanchez'), +(6, 6, 'Side computer feeling smile less medical.', 'Leah Boyd'), +(6, 1, 'Animal listen usually outside fine yard.', 'Kimberly Brennan'), +(6, 2, 'Street police low film your.', 'Anthony Johnson'), +(6, 8, 'Feeling catch say agree the cell region provide friend people.', 'Steven Haynes'), +(6, 10, 'Build player even main daughter why bar.', 'Maria Kemp'), +(7, 4, 'Put real staff many.', 'Jon Hester'), +(7, 5, 'Everybody ago carry product.', 'Emily Robinson'), +(7, 3, 'Another state environmental one.', 'Matthew Duran'), +(7, 9, 'Experience effort beyond model.', 'Sarah Howard'), +(7, 10, 'Capital project story dog.', 'Patricia Walker'), +(7, 7, 'Write among forward provide east fine compare.', 'Ian Chang'), +(7, 3, 'Kitchen behind data add whole message interview expert police someone low.', 'Jessica Jimenez'), +(7, 4, 'North power main here explain glass wish.', 'Michael Smith'), +(7, 1, 'Suffer region even its dark.', 'Kimberly Johnson PhD'), +(7, 3, 'Dinner newspaper where.', 'Jessica Williams'), +(7, 7, 'Argue brother stuff become rest artist.', 'Kimberly Brown'), +(7, 9, 'Big think go fine sure ago.', 'Emily Martinez'), +(7, 3, 'Protect energy nice society believe else president surface mission hit way now.', 'Judy Ortiz'), +(8, 2, 'Evidence city allow skill investment I gun speech bank team help hour.', 'Joseph Rivas'), +(8, 8, 'There office good language ago thus product board thing good power remain.', 'Steven Barton'), +(8, 9, 'Size others local decade.', 'Justin Hall'), +(8, 6, 'Nice everyone race consumer staff community from.', 'Daniel Soto'), +(8, 6, 'Impact him win wish article road network.', 'Suzanne Nguyen MD'), +(8, 10, 'Teacher sport argue time draw help consumer second meeting camera yeah camera.', 'Jason Johnson'), +(8, 2, 'Matter your meeting how.', 'Erin Huff'), +(8, 2, 'Officer benefit space away.', 'Joe Espinoza'), +(8, 10, 'Partner final catch.', 'Laura Ewing'), +(8, 10, 'Matter politics reach tend alone.', 'Julie Bishop'), +(8, 5, 'Wonder tree morning chance lot could state structure color.', 'Emily Fisher'), +(8, 7, 'Recent particular even word lot remember maybe drug.', 'Tyler Bishop'), +(8, 4, 'Final all environmental.', 'Frank Dickerson'), +(9, 6, 'Event oil control sort yet staff language man summer.', 'Christine Stewart'), +(9, 5, 'Focus gun environmental until kitchen three.', 'Mr. Sean Shah'), +(9, 5, 'Candidate area send art answer low themselves.', 'Jessica Castro'), +(9, 2, 'Run within consumer where.', 'Steven Anderson'), +(9, 6, 'The whole six occur resource over more product.', 'Dustin Serrano'), +(9, 7, 'International drug lay appear onto.', 'Hannah Ellis'), +(9, 9, 'Else sure pattern help minute once recognize.', 'Dakota Mcknight'), +(9, 6, 'Large near part music part manager.', 'Matthew Barajas'), +(9, 3, 'Clear prove.', 'Steven Chambers'), +(9, 4, 'Partner reveal strategy culture cost against hold pay.', 'Jennifer Chase'), +(9, 7, 'Budget all forward style price.', 'Joseph Marshall'), +(9, 7, 'Strong traditional today myself physical education theory in sound loss.', 'Brittany Parrish'), +(9, 7, 'Participant region send.', 'George Carney'), +(10, 5, 'If these likely film.', 'Peter Gonzalez'), +(10, 6, 'Walk mother actually professor marriage.', 'Monica Koch'), +(10, 9, 'Second deep impact agent would.', 'Trevor Gillespie'), +(10, 2, 'Include only idea democratic father.', 'Sandra Shea'), +(10, 5, 'Across line unit care time pressure.', 'Melissa Tucker'), +(10, 2, 'Over reveal create pay PM wonder condition family nature position church.', 'Julie Underwood'), +(10, 7, 'Article weight them international news born.', 'Anthony Wheeler'), +(10, 2, 'Interest very piece.', 'Elizabeth Anderson DDS'), +(10, 9, 'Best since community democratic tax somebody.', 'Christopher Hernandez'), +(10, 9, 'General college soldier arrive life politics crime talk hundred poor interview issue this.', 'Kelly Sharp MD'), +(10, 6, 'Write seem itself close treat.', 'Melissa Wolf'), +(10, 1, 'Call meeting agreement before we sign civil.', 'Kelsey Horn'), +(10, 8, 'In hair opportunity goal store tell among finally participant.', 'Michael Thompson'), +(11, 10, 'Reason policy each participant.', 'Andrew Smith'), +(11, 8, 'How factor available down.', 'Daniel Carr'), +(11, 4, 'Be per management strong enjoy election window person region.', 'Joel Smith'), +(11, 4, 'Show produce tax own lawyer than science tonight.', 'Alex Rose'), +(11, 6, 'Ok phone wide shake among can business effort feel science.', 'Greg Olsen'), +(11, 7, 'Simple practice across financial old final feeling.', 'Matthew Hernandez'), +(11, 1, 'Pattern travel difficult consider.', 'Victoria Thompson'), +(11, 2, 'Size course we itself side clear.', 'Stacie Thornton'), +(11, 6, 'Energy already down finish because current product we me.', 'Eric Johnson'), +(11, 9, 'Necessary upon north place.', 'Christopher Johnson'), +(11, 8, 'Memory marriage under admit should seem person.', 'Barbara Robertson'), +(11, 9, 'Threat material base process stage that realize plant.', 'Gary Diaz'), +(11, 1, 'Create plant either small hundred land control.', 'Mrs. Kaitlyn Delacruz'), +(12, 3, 'Over continue again bit by.', 'Amber Morris'), +(12, 9, 'Gas market laugh security management edge back these house.', 'Travis Rosales'), +(12, 7, 'Attention responsibility hot main full.', 'Travis Glenn'), +(12, 1, 'Its plan few coach eye challenge.', 'Ms. Chelsea Ayers'), +(12, 8, 'Travel several structure fly.', 'Robert Davis'), +(12, 3, 'A claim least thing off reality.', 'Erin Davis'), +(12, 8, 'Beat finish response central assume offer.', 'Crystal Parker'), +(12, 2, 'Thing without occur his.', 'Joel Sanders'), +(12, 6, 'Recognize miss while measure turn.', 'Valerie Guzman'), +(12, 1, 'Such such between pattern discuss major.', 'Bethany Sharp'), +(12, 2, 'Could law impact order remain happy ask fire glass.', 'Nicole Anderson'), +(12, 7, 'Eat similar drive.', 'Jack Yang'), +(12, 10, 'Capital strong collection weight food either a range law quite manager certain own.', 'Miranda Wright'), +(13, 10, 'Sea become next edge clearly machine alone couple.', 'Daniel Potter'), +(13, 5, 'Arrive paper dinner up light group.', 'Steven Hubbard'), +(13, 10, 'Create blue these best few player couple leg.', 'Michelle Atkinson'), +(13, 1, 'Wall stage affect.', 'Ashley Chang'), +(13, 9, 'Return nearly recent political between.', 'Jonathan Singleton'), +(13, 6, 'Control store situation thing painting send total future.', 'Lauren Savage'), +(13, 4, 'Continue positive range nation his wonder response.', 'Rose Thompson'), +(13, 10, 'Personal final money whom practice box scene box.', 'John Ashley'), +(13, 7, 'Write between with.', 'Daniel Peck'), +(13, 4, 'Whether training bed yard assume.', 'Mrs. Lori Robertson PhD'), +(13, 4, 'Represent although police policy small hold live remain color society particular hit ten.', 'Sierra Gomez'), +(13, 2, 'Blood at.', 'Ariel Henderson'), +(13, 7, 'Well friend peace.', 'Steven Wright'), +(14, 9, 'Place lead hear safe class.', 'Scott Walls'), +(14, 9, 'Generation budget we week yeah decade thing upon make week any.', 'Nicole Burgess'), +(14, 5, 'Guy last visit else act once must president help her community.', 'James Crawford'), +(14, 6, 'Room summer care color none want.', 'Breanna Mendez'), +(14, 10, 'Where guy assume will.', 'Dylan Schmidt'), +(14, 6, 'Board participant step physical garden perhaps.', 'Megan Pitts'), +(14, 7, 'Tell treatment start not but already.', 'Cathy Young'), +(14, 2, 'Certainly direction accept must.', 'Charles Garcia'), +(14, 7, 'Ok wonder pressure worry.', 'Melissa Taylor'), +(14, 1, 'Student experience challenge eye market different cut discover morning.', 'Joseph Griffith'), +(14, 5, 'Here billion run west car.', 'Curtis Robinson'), +(14, 1, 'Defense open nation leader past the bit.', 'Jack Miller'), +(14, 8, 'City possible region.', 'Jeffrey Hunter'), +(15, 3, 'Leave school former pressure.', 'Emily Turner'), +(15, 10, 'Reduce threat bad into safe test bag business.', 'Christina Barnett'), +(15, 4, 'Recently improve take actually.', 'Tracey Key'), +(15, 4, 'Population beyond professional herself.', 'Rodney Lewis'), +(15, 2, 'Television development meeting deal if what pattern another possible high.', 'Clifford Evans'), +(15, 8, 'Ahead entire popular forget computer serious.', 'Courtney Perry'), +(15, 5, 'Case real civil relate.', 'Jennifer Bishop'), +(15, 8, 'Sure value win card image sound buy.', 'Regina Buckley'), +(15, 6, 'Guess teach fact finish artist.', 'Mackenzie Waters'), +(15, 4, 'Significant democratic white order beat.', 'David Bush'), +(15, 5, 'Financial himself view two.', 'Kelly Greer'), +(15, 4, 'Together why response public or.', 'Charlene Austin'), +(15, 4, 'Way weight talk each from decision yes lot continue window.', 'Heather Sanchez'), +(16, 4, 'People with at three simply.', 'Dr. Angel Williams'), +(16, 9, 'Popular baby upon physical money explain for finally that action a at.', 'Howard Schmidt'), +(16, 4, 'Several agency process every.', 'Patricia Bennett'), +(16, 9, 'Particularly toward participant.', 'Anne Kramer'), +(16, 4, 'Practice rest set cold effect election.', 'Theresa Andrews'), +(16, 5, 'Yard cold well smile represent whom win.', 'Patricia Abbott'), +(16, 7, 'Professional certain ten themselves modern paper federal three.', 'Gina Rodriguez'), +(16, 1, 'Court every modern true few.', 'Brenda Brown'), +(16, 8, 'Eye move majority several someone certainly leader between meet nature.', 'Richard Ware'), +(16, 3, 'Save building bar important American.', 'Linda Larsen'), +(16, 4, 'There national cause most stop.', 'Paige Carey'), +(16, 1, 'Fish security popular there.', 'Bobby Lewis'), +(16, 8, 'Heavy three wall worker seven action.', 'Thomas Dennis'), +(17, 2, 'Ago interest yourself say weight crime American pay care table break will.', 'Carlos Garner'), +(17, 8, 'With action born city act.', 'Thomas Wise'), +(17, 3, 'Positive might sometimes.', 'Patrick Hutchinson'), +(17, 8, 'Turn project station option indeed player true.', 'Paul Stewart'), +(17, 8, 'Of note though.', 'Jessica Ryan'), +(17, 7, 'Meet energy attention address serve television current officer section country particularly.', 'Benjamin Cortez'), +(17, 6, 'Car public boy area term significant.', 'Michael Mcpherson'), +(17, 8, 'Young street democratic local gun food public.', 'Mary Smith'), +(17, 7, 'Half fine morning country.', 'Joseph Spears'), +(17, 6, 'Material doctor officer.', 'Tony Nelson'), +(17, 4, 'Phone pick recently either.', 'Christopher Rodriguez'), +(17, 3, 'Music go poor maintain listen discover subject leg ten research.', 'David Nelson'), +(17, 6, 'Can program Mrs tough almost.', 'Susan Rhodes'), +(18, 2, 'Energy American against forward show.', 'Heather Anderson'), +(18, 2, 'Among remember wish.', 'Barry Hess'), +(18, 4, 'Beautiful whose personal face beat drive from lawyer industry around.', 'Kimberly Martinez'), +(18, 1, 'Page customer give policy lawyer quality act security before small bed.', 'Robert Jones'), +(18, 4, 'Above structure tough add such.', 'Dr. Melissa Wilson'), +(18, 2, 'Action letter result song collection book.', 'Pamela Henderson'), +(18, 9, 'Degree body major better easy trip stock ago assume its.', 'Michelle Sanders'), +(18, 3, 'Very drop least outside total whatever.', 'Theresa Thompson'), +(18, 7, 'Record question may once.', 'Kimberly Scott'), +(18, 5, 'Should will or fine race special first.', 'Douglas Russo'), +(18, 4, 'On let individual form there.', 'Christopher Villa'), +(18, 8, 'Environmental group need manage vote behind.', 'Brian Wilcox'), +(18, 3, 'Also economy would simple phone far shake today success region beyond.', 'Patricia Martin'), +(19, 2, 'Respond marriage safe wall site network something the.', 'Daniel Davis'), +(19, 1, 'Chair system left a rule window.', 'Joseph Walls'), +(19, 10, 'Reason pressure sea believe article science.', 'Thomas Perry'), +(19, 6, 'Ten wait get federal live record.', 'Daniel Robinson'), +(19, 4, 'Recent education wall group blue enter.', 'Robert Elliott'), +(19, 10, 'Economy good little plant mother.', 'Amanda Ruiz'), +(19, 10, 'Model fish quite Democrat.', 'Tiffany Hart'), +(19, 10, 'Low increase bed should.', 'Bethany Banks'), +(19, 3, 'Energy job wrong ball peace plant.', 'Jennifer Dougherty'), +(19, 7, 'Stay tell quickly different get early manager throw.', 'Matthew Cook'), +(19, 10, 'Second it trip eye myself available scientist his size real.', 'Edwin Clark'), +(19, 8, 'Good whatever threat purpose.', 'Shelby Callahan'), +(19, 10, 'Attention action American provide stop.', 'James Garcia'), +(20, 6, 'Ago theory service focus necessary individual keep this stand.', 'Kevin Brandt'), +(20, 7, 'Bad offer past unit I itself recognize event interview.', 'Kevin Roberts'), +(20, 3, 'According task rule federal all might very can computer serve before join.', 'Malik Leon'), +(20, 10, 'Value present a town cover standard mention answer most.', 'Carl Sexton'), +(20, 1, 'Ever school month my wear his international ten.', 'Phillip Arnold'), +(20, 6, 'Though miss teach baby some whole week.', 'Scott Bowman'), +(20, 1, 'Focus clear nation artist new carry message.', 'Amy Mills'), +(20, 8, 'Real remain firm home range week.', 'Lisa Williams'), +(20, 9, 'Artist without democratic which officer.', 'Anthony Gamble'), +(20, 5, 'Ability week somebody article word.', 'James Stuart'), +(20, 10, 'Knowledge management push anyone six theory.', 'William Wallace'), +(20, 2, 'Question seek for hope he happy man bar law free full heart.', 'Amy Odonnell'), +(20, 4, 'Understand character.', 'Amanda Clements'), +(21, 1, 'Southern black plan record fly possible.', 'Monica Cohen'), +(21, 10, 'Popular agent war detail.', 'Sandra Murphy'), +(21, 9, 'This score why.', 'Timothy Hernandez'), +(21, 7, 'Try part yeah heart type.', 'Craig Waller'), +(21, 6, 'Lot about understand leave.', 'Jose Santos'), +(21, 1, 'Must need performance hot control not garden.', 'Glen Baker'), +(21, 7, 'Ahead card product for leader provide general stuff thought.', 'Alexandria Perez'), +(21, 3, 'Total take the cost.', 'Dylan Liu'), +(21, 5, 'Floor near street art identify pay check direction agent do peace sell Mrs.', 'Angela Thomas'), +(21, 6, 'Political tend.', 'Christina Wood'), +(21, 9, 'Build sure prepare left.', 'Laura Marshall'), +(21, 10, 'Be human minute form wind partner feel check foot.', 'Krista Brown'), +(21, 7, 'Reflect director reflect walk yourself water stage second.', 'Scott Cochran'), +(22, 1, 'Tv well.', 'Michael Baker'), +(22, 1, 'Again once turn subject position grow material nice list inside threat why.', 'Jeffrey Liu'), +(22, 1, 'Produce maintain expect whatever letter so sure here civil.', 'Leslie Greene'), +(22, 2, 'It media our war.', 'Tina Hull'), +(22, 9, 'Heart bad value vote.', 'Michael Murray'), +(22, 3, 'Hand knowledge green race inside single tonight teacher perform individual.', 'William Phillips'), +(22, 5, 'Technology feeling as turn attorney determine.', 'Raymond Vega'), +(22, 3, 'Draw by herself including off yet bill.', 'Sharon Tran'), +(22, 6, 'However choose law already design.', 'Hailey King'), +(22, 6, 'Ground view answer decade feeling response building end.', 'Charles Burton'), +(22, 2, 'Eight wall clear somebody truth.', 'Christy Wilcox'), +(22, 4, 'Method minute claim kid detail.', 'Catherine Williams'), +(22, 9, 'Artist resource what next image society reason.', 'Denise Martin'), +(23, 7, 'Free represent budget conference.', 'Mr. James Watts'), +(23, 9, 'Trade us amount.', 'Joseph Moore'), +(23, 10, 'View information bit part foreign region design behavior behind.', 'Timothy Clark'), +(23, 5, 'Thank remain suddenly enjoy deal daughter point account example east bad.', 'Jason Smith'), +(23, 1, 'Interest name contain when learn record center foot continue.', 'Jamie Nicholson'), +(23, 4, 'Democrat throw force reason attorney.', 'Dr. Kimberly Webb DDS'), +(23, 6, 'Hot yeah last discover way by.', 'Kristina Finley'), +(23, 4, 'Close more doctor someone space throw.', 'Daniel Curtis'), +(23, 8, 'Today word language visit behind job wonder sign.', 'Daniel Pearson'), +(23, 6, 'Argue edge use job.', 'Carol Moore'), +(23, 3, 'Cultural kitchen open away.', 'Megan Harrison'), +(23, 9, 'Could low south accept water short positive me.', 'Megan Cabrera'), +(23, 10, 'Media professor company year.', 'Charles Leonard'), +(24, 2, 'Week somebody arm.', 'Catherine Vaughn'), +(24, 9, 'Onto win window.', 'Charles Singh'), +(24, 6, 'Off lay director cut phone.', 'Lori Garcia'), +(24, 1, 'Population TV call million policy increase knowledge.', 'Gloria Morgan'), +(24, 5, 'Trial in such husband continue believe.', 'Jordan Reid'), +(24, 2, 'Best democratic future.', 'Joshua Cochran'), +(24, 9, 'Century discussion event support market brother him direction.', 'Katherine Dean'), +(24, 5, 'South laugh quite.', 'Heather Parks'), +(24, 10, 'Pay finally research say forward into action.', 'Sherry Smith'), +(24, 6, 'Important effort.', 'Penny Cuevas'), +(24, 8, 'When clearly full explain.', 'Lacey Taylor'), +(24, 9, 'Firm eat every painting some like message administration.', 'Aaron Armstrong'), +(24, 4, 'Seek read reflect wide country year idea memory soon wide.', 'Sheryl Brock'), +(25, 9, 'Research occur hot green role.', 'Richard Rodgers'), +(25, 4, 'Central pay reach couple hotel more amount else.', 'William Ramos'), +(25, 6, 'Particularly reach me bar strategy agree.', 'Sharon Butler'), +(25, 5, 'Western several project pay music drop.', 'Sierra Rogers'), +(25, 4, 'Establish bring news color add find to serve.', 'Daniel Alexander'), +(25, 4, 'Friend of president senior factor car open place business.', 'Justin Lloyd'), +(25, 4, 'Change through buy serious commercial mouth act.', 'Angela Rodgers'), +(25, 9, 'Finally offer father for.', 'Tanner Mcclure'), +(25, 6, 'Could rest southern.', 'Jeffrey May'), +(25, 9, 'Our hair capital foreign there long many.', 'Tracy Miles'), +(25, 8, 'Guess safe entire stage expert talk involve candidate book office feel start wait.', 'Mrs. Grace Frost DDS'), +(25, 3, 'Sit be key foot PM.', 'Kim Young'), +(25, 9, 'Nature land memory current talk event.', 'Stephen Harding'), +(26, 1, 'Manage agent say best detail boy what sing.', 'Daniel Johnson'), +(26, 4, 'Floor face big order participant.', 'Michael Norton'), +(26, 7, 'Knowledge certainly summer.', 'Jennifer Owens'), +(26, 6, 'Property type environmental hear hold system weight both.', 'Michelle Hansen'), +(26, 9, 'International this three development.', 'Philip Brown'), +(26, 10, 'Plan assume artist tonight certainly senior plant hundred air glass analysis.', 'Joshua Bailey'), +(26, 5, 'Development rule product.', 'Ashley Kim'), +(26, 5, 'Data probably want these girl next business.', 'Edward Ramos'), +(26, 4, 'Draw instead call girl remember part something rule street cold.', 'Gerald Young'), +(26, 5, 'Able art change car approach.', 'Deborah Banks'), +(26, 2, 'View maybe program after month learn bit school store.', 'Brenda Young'), +(26, 3, 'Child measure certain.', 'Kathryn Lee'), +(26, 4, 'Hotel manage cold Democrat contain artist hotel spring present.', 'Megan Martin'), +(27, 6, 'The stock final lead poor.', 'Sheila Duncan'), +(27, 5, 'Per life right during success although.', 'Thomas Evans'), +(27, 8, 'Message future religious.', 'Lauren Reed'), +(27, 4, 'Evening already modern decide opportunity hundred person reality major traditional her until.', 'Derrick Roberts'), +(27, 1, 'Eat environmental couple budget contain them.', 'Aaron Keller'), +(27, 5, 'Enough against husband general fire could consumer drug.', 'Karla Roach'), +(27, 4, 'Later woman morning state also shoulder.', 'James Johnson'), +(27, 3, 'Return on public.', 'Sean Mccarthy'), +(27, 7, 'Themselves yeah per give.', 'Teresa Meza'), +(27, 7, 'Choose appear speak certain we on language approach off store along.', 'Wesley Flores'), +(27, 6, 'Yard fund ground staff chair.', 'Jason Harris'), +(27, 6, 'Kid beyond read health boy stock the.', 'Andrew Long'), +(27, 10, 'Here politics board nice dinner onto public green.', 'Christopher Webster'), +(28, 6, 'Human treatment hundred end operation.', 'Bruce Mckee'), +(28, 6, 'Detail best mention above cost.', 'Michael Thompson'), +(28, 8, 'Environmental letter middle gas social writer reason issue but.', 'Rhonda Lucero'), +(28, 3, 'Fear current structure source sing book example especially.', 'Danielle Thomas'), +(28, 9, 'So property too.', 'Carl Wallace'), +(28, 1, 'Certainly base street tough business.', 'Isabella Hoffman'), +(28, 9, 'Do another practice summer bill certain.', 'Crystal Carter'), +(28, 10, 'Serious member north maybe building vote history at their.', 'Matthew Kirby'), +(28, 9, 'Executive section Democrat doctor help choice.', 'Ryan Clarke'), +(28, 4, 'Director which.', 'John Norman'), +(28, 6, 'Develop heavy boy wife.', 'Jamie Carter'), +(28, 2, 'Focus enjoy personal good professor PM throughout.', 'Chase Kennedy'), +(28, 8, 'Whether value day student.', 'Jacob Ritter'), +(29, 9, 'Central cup see message technology kind step ball detail.', 'Gregory Thompson'), +(29, 7, 'Food reason cost.', 'Marcus Rodriguez'), +(29, 6, 'Bag each scene yet development meet thing table general.', 'Katelyn Jensen'), +(29, 7, 'Difficult age really beyond few even.', 'Paul Rowland'), +(29, 2, 'Learn tree director here leader.', 'Michelle Marquez'), +(29, 10, 'Build sure available soon produce military cold.', 'Paul Little'), +(29, 5, 'High herself new human surface.', 'Jason Thomas'), +(29, 4, 'Performance travel drop miss.', 'Nicholas Hunt'), +(29, 8, 'Build rule take pass night begin whatever.', 'Mary Brown'), +(29, 7, 'Evening government most baby investment than evidence young particular especially.', 'Christine Johnson'), +(29, 7, 'She age point final.', 'Reginald Schroeder'), +(29, 9, 'Official increase crime loss issue.', 'Ryan Potter'), +(29, 4, 'Specific education artist after set team.', 'Shannon Campbell'), +(30, 3, 'Government talk talk.', 'Martin Woods'), +(30, 10, 'Institution teacher find drop school individual.', 'Rebecca Wheeler'), +(30, 9, 'Military hospital drug.', 'Christine Townsend'), +(30, 10, 'Charge store land cold professional central.', 'Latoya Simpson'), +(30, 7, 'Song really attack ready employee here specific attention who able plant fast.', 'Jose Jackson'), +(30, 2, 'Hour relationship down end.', 'Alexander Collins'), +(30, 7, 'Partner bank still group reality key analysis.', 'Debra Flores'), +(30, 8, 'Former certain lawyer civil with name between list spend.', 'Mark Singleton'), +(30, 5, 'Kind wish enjoy room none know discussion.', 'Carol French'), +(30, 2, 'Professor suffer certain same reveal you.', 'Faith Cain'), +(30, 8, 'Dinner start its American its offer fast.', 'Heidi Harrington'), +(30, 4, 'Better would never they.', 'Adam Flores'), +(30, 10, 'Money score investment draw.', 'Michelle Reyes'), +(31, 3, 'Senior floor occur present cover decision place detail writer huge better behavior election.', 'Michelle Reed'), +(31, 10, 'Respond vote state figure evidence.', 'Austin Hobbs'), +(31, 4, 'Test sometimes billion anything know cultural enough could able film different.', 'Mark Miller'), +(31, 5, 'Set lawyer stop doctor court even continue than clear.', 'Eric Cook'), +(31, 5, 'Admit data certain join everything thought believe meet seem.', 'Christopher Aguilar'), +(31, 6, 'Above clearly evidence example whom.', 'Deborah Cooper'), +(31, 3, 'Issue from raise dinner politics like.', 'Ashley Fox'), +(31, 10, 'Here future manager treat bill live consumer since when expert.', 'Mr. Anthony Sullivan'), +(31, 1, 'Factor start report.', 'Tina Rodriguez'), +(31, 8, 'Course garden image analysis wrong human imagine miss.', 'Alexa Sanchez'), +(31, 8, 'Various everyone game seek throw prepare.', 'Audrey James'), +(31, 8, 'Such take early method here image.', 'Jennifer Perkins'), +(31, 3, 'Attorney these glass say any population off stand run.', 'James Weaver'), +(32, 2, 'Chance huge society shake media picture organization yourself suffer.', 'Philip Haas'), +(32, 1, 'Score blood look modern less.', 'Scott Manning'), +(32, 8, 'Third sense tonight media.', 'Sarah Johnson'), +(32, 10, 'Cup expect report which film these pretty writer even.', 'Charles Ray PhD'), +(32, 9, 'Not base understand.', 'Robert Clark MD'), +(32, 1, 'His one group radio people huge article.', 'Joel Smith'), +(32, 9, 'Must design research person office.', 'Todd Simmons'), +(32, 1, 'Head call by large doctor seek not.', 'Paul Stein'), +(32, 9, 'Carry wish now be evening just actually hard special industry Democrat.', 'Karen Frye'), +(32, 3, 'Your mouth area never experience part simply himself.', 'Ms. Marisa Pollard'), +(32, 3, 'Ok front without quite idea.', 'Steven Valdez'), +(32, 8, 'Tonight yes remain new.', 'Sean Terry'), +(32, 9, 'Nice system view particular mother task real leg surface suddenly phone.', 'Lauren Rios'), +(33, 10, 'Establish better three.', 'Traci Perry'), +(33, 10, 'Building difficult responsibility around.', 'Adam Roberts'), +(33, 5, 'Work need increase event sport fill owner sort.', 'Heather Pierce'), +(33, 8, 'Walk two fish choose point bank.', 'Mark Alexander'), +(33, 1, 'Suggest five front.', 'Matthew Braun'), +(33, 1, 'Amount nearly on wall result.', 'Shelby Taylor'), +(33, 6, 'Hot listen I part probably.', 'Cheryl Vasquez'), +(33, 7, 'Good try ok food if.', 'Devin Holt'), +(33, 4, 'Military during face bar nation worker since drug benefit.', 'Rebecca Gutierrez'), +(33, 10, 'Nor service one music talk radio measure up sometimes sound strategy among.', 'Angela Taylor'), +(33, 2, 'Song story force what contain student why.', 'Melissa Greene'), +(33, 6, 'Bar than cost attack.', 'Jeff Bullock'), +(33, 10, 'Wear party tree foreign maybe cost management group artist level after.', 'Jennifer Day'), +(34, 6, 'Line he ok able husband with any drive.', 'Ralph Johnson'), +(34, 5, 'Heavy important fine.', 'Leslie Parks PhD'), +(34, 6, 'Important head official market professional also happy building point house.', 'Christina Jimenez'), +(34, 5, 'Method create just.', 'Eric Haley'), +(34, 2, 'Only among fill age.', 'Kyle Herman'), +(34, 6, 'Late try sign quality small explain.', 'Kathleen Wilson'), +(34, 6, 'Yourself Congress international air despite movie.', 'Barbara Newton'), +(34, 7, 'Statement sport pretty central consumer.', 'Michele Flores'), +(34, 4, 'Region believe where mind heavy rich nation high value.', 'Daniel Thomas'), +(34, 7, 'Shoulder national music inside else until fast response water country.', 'Jill Brooks'), +(34, 9, 'Admit issue space plant make.', 'Michael Lynch'), +(34, 5, 'Space data seek garden.', 'Stephanie White'), +(34, 9, 'Center myself away without between win anything doctor.', 'Jessica Porter'), +(35, 4, 'Your writer.', 'Scott Gilbert'), +(35, 3, 'Manager ball know now president.', 'Melissa Williams'), +(35, 1, 'Cut organization moment hard performance thousand figure whose close.', 'Victor Chapman'), +(35, 5, 'The employee rock hundred when guy network.', 'Isabella Torres'), +(35, 4, 'Try affect green similar project general at clear question then thing town.', 'Katherine Nelson'), +(35, 4, 'Item traditional lawyer line son author fear far which record easy politics.', 'James Mclaughlin'), +(35, 5, 'Military identify expect once moment forward move.', 'Rachel Lee'), +(35, 1, 'Per final marriage one sense.', 'Daniel Francis'), +(35, 3, 'Conference option between pull send project responsibility.', 'Elizabeth Torres'), +(35, 10, 'Enjoy particularly address bill that control five card.', 'Daniel Evans'), +(35, 4, 'Agency attorney may boy friend.', 'Matthew Davis'), +(35, 1, 'Hotel threat science sound add throughout.', 'Joseph Diaz'), +(35, 5, 'Energy American occur society thousand when market second.', 'Kimberly Gallagher'); diff --git a/projekt_2/pom.xml b/projekt_2/pom.xml new file mode 100644 index 0000000..b9dbf9a --- /dev/null +++ b/projekt_2/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + + org.example + projekt_2 + 1.0-SNAPSHOT + + + 21 + 21 + UTF-8 + + + + + org.hibernate.orm + hibernate-core + 6.4.1.Final + + + org.postgresql + postgresql + 42.2.20 + + + junit + junit + 4.13.2 + test + + + org.junit.jupiter + junit-jupiter + RELEASE + test + + + org.eclipse.jdt + ecj + 3.28.0 + + + org.mockito + mockito-core + 4.8.0 + test + + + + \ No newline at end of file diff --git a/projekt_2/projekt_2.iml b/projekt_2/projekt_2.iml new file mode 100644 index 0000000..39cf9e3 --- /dev/null +++ b/projekt_2/projekt_2.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/projekt_2/src/main/java/org/example/Author.java b/projekt_2/src/main/java/org/example/Author.java new file mode 100644 index 0000000..9dddb08 --- /dev/null +++ b/projekt_2/src/main/java/org/example/Author.java @@ -0,0 +1,49 @@ +package org.example; + +import jakarta.persistence.*; + +import java.util.List; + +@Entity +@Table(name = "authors") +public class Author { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "author_id") + private Long id; + + @Column(name = "name") + private String name; + + @OneToMany(mappedBy = "author", cascade = CascadeType.ALL, orphanRemoval = true) + private List books; + + public Author() { + } + + // Getters and setters + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getBooks() { + return books; + } + + public void setBooks(List books) { + this.books = books; + } +} diff --git a/projekt_2/src/main/java/org/example/Book.java b/projekt_2/src/main/java/org/example/Book.java new file mode 100644 index 0000000..e498230 --- /dev/null +++ b/projekt_2/src/main/java/org/example/Book.java @@ -0,0 +1,54 @@ +package org.example; + +import jakarta.persistence.*; + +@Entity +@Table(name = "books") +public class Book { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "book_id") + private Long id; + + private String title; + + @ManyToOne + @JoinColumn(name = "author_id") + private Author author; + + public Book() { + } + + public Long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Author getAuthor() { + return author; + } + + public void setAuthor(Author author) { + this.author = author; + } + + @Override + public String toString() { + return "Book{" + + "id=" + id + + ", title='" + title + '\'' + + '}'; + } +} diff --git a/projekt_2/src/main/java/org/example/BookDetails.java b/projekt_2/src/main/java/org/example/BookDetails.java new file mode 100644 index 0000000..627d2f7 --- /dev/null +++ b/projekt_2/src/main/java/org/example/BookDetails.java @@ -0,0 +1,78 @@ +package org.example; + +import jakarta.persistence.*; + +@Entity +@Table(name = "book_details") +public class BookDetails { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "details_id") + private Long id; + + @Column(name = "page_count") + private int pageCount; + + private String isbn; + + @OneToOne + @JoinColumn(name = "book_id", referencedColumnName = "book_id") + private Book book; + + @ManyToOne + @JoinColumn(name = "author_id") + private Author author; + + public BookDetails() { + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Author getAuthor() { + return author; + } + + public void setAuthor(Author author) { + this.author = author; + } + + public int getPageCount() { + return pageCount; + } + + public void setPageCount(int pageCount) { + this.pageCount = pageCount; + } + + public String getIsbn() { + return isbn; + } + + public Book getBook() { + return book; + } + + public void setBook(Book book) { + this.book = book; + } + + public void setIsbn(String isbn) { + this.isbn = isbn; + } + + @Override + public String toString() { + return "BookDetails{" + + "id=" + id + + ", author=" + author + + ", pageCount=" + pageCount + + '}'; + } +} diff --git a/projekt_2/src/main/java/org/example/Main.java b/projekt_2/src/main/java/org/example/Main.java new file mode 100644 index 0000000..3687d75 --- /dev/null +++ b/projekt_2/src/main/java/org/example/Main.java @@ -0,0 +1,66 @@ +package org.example; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.hibernate.cfg.Configuration; + +import java.util.List; +import java.util.Scanner; + +public class Main { + + public static void main(String[] args) { + + // configure the db connection + Configuration configuration = new Configuration(); + configuration.configure("hibernate.cfg.xml"); + SessionFactory sessionFactory = configuration.buildSessionFactory(); + + try (Session session = sessionFactory.openSession()) { + + MyQuery myQuery = new MyQuery(session); + + // here, replace "test" with the title of the book you want to query + String title1 = "test"; + myQuery.getBookByExactTitle(title1); + + // here, replace "test" with the title of the book you want to query + String title2 = "test"; + myQuery.getBookDetailsWithAuthorByTitle(title2); + + // here, set the book id you want to query + Long id = 1L; + // here, set page number and page size + int pageNumber = 1; + int pageSize = 10; + myQuery.getBookReviewsByBookId(id, pageNumber, pageSize); + + Transaction tx = null; + try { + tx = session.beginTransaction(); + // create a book + Book book = MyQuery.createBook("test title 3"); + session.save(book); + + // create an Author + Author author = MyQuery.createAuthor("adam 3"); + session.save(author); +// + // create book details + BookDetails bookDetails = MyQuery.createBookDetails("333123123", 123, book, author); + session.save(bookDetails); +// + tx.commit(); + } catch (Exception e) { + if (tx != null) { + tx.rollback(); + } + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + sessionFactory.close(); + } + } +} \ No newline at end of file diff --git a/projekt_2/src/main/java/org/example/MyQuery.java b/projekt_2/src/main/java/org/example/MyQuery.java new file mode 100644 index 0000000..362d264 --- /dev/null +++ b/projekt_2/src/main/java/org/example/MyQuery.java @@ -0,0 +1,126 @@ +package org.example; + +import com.sun.jdi.request.StepRequest; +import org.hibernate.Session; +import org.hibernate.query.Query; + +import java.time.ZonedDateTime; + +import java.util.List; + +public class MyQuery { + + Session session; + + public MyQuery(Session session) { + this.session = session; + } + + // ======================== SELECTing from the database ================================= + public List getBookByExactTitle(String title) { + String q = "SELECT b.id, b.title " + + "FROM Book b " + + "WHERE b.title = :title"; + + Query query = session.createQuery(q, Object[].class) + .setParameter("title", title); + + for (Object[] result : query.getResultList()) { + System.out.println("id = " + result[0]); + System.out.println("title = " + result[1]); + } + + return query.getResultList(); + } + + public List getBookDetailsWithAuthorByTitle(String title) { + + String q = "SELECT " + + "bd.details_id, bd.page_count, bd.isbn, " + + "b.title AS book_title, " + + "a.name AS author_name " + + "FROM book_details bd " + + "JOIN books b ON bd.book_id = b.id " + + "JOIN authors a ON bd.author_id = a.author_id " + + "WHERE b.title = :given_title"; + + Query query = session.createNativeQuery(q, Object[].class) + .setParameter("given_title", title); + List resultList = query.getResultList(); + + for (Object[] result : resultList) { + System.out.println("details_id = " + result[0]); + System.out.println("page_count = " + result[1]); + System.out.println("isbn = " + result[2]); + System.out.println("book_title = " + result[3]); + System.out.println("author_name = " + result[4]); + } + System.out.println("--------------------------"); + + return resultList; + } + + public List getBookReviewsByBookId(Long id, int page, int pageSize) { + + // calculate LIMIT and OFFSET + int limit = pageSize; + int offset = (page - 1) * pageSize; + + String q = "SELECT * " + + "FROM reviews " + + "WHERE book_id = :given_id " + + "LIMIT :limt " + + "OFFSET :offst"; + + Query query = session.createNativeQuery(q, Object[].class) + .setParameter("given_id", id) + .setParameter("limt", limit) + .setParameter("offst", offset); + List resultList = query.getResultList(); + + if (resultList.isEmpty()) { + System.out.println("No reviews found for the given book id and page."); + return null; + } + + for (Object[] result : resultList) { + System.out.println("review_id = " + result[0]); + System.out.println("book_id = " + result[1]); + System.out.println("rating = " + result[2]); + System.out.println("review_text = " + result[3]); + System.out.println("author_name = " + result[4]); + } + System.out.println("--------------------------"); + + return resultList; + } + // ======================== END of SELECTing ================================= + + + // ======================== INSERTing into the database ================================= + public static Book createBook(String bookTitle) { + Book book = new Book(); + book.setTitle(bookTitle); + +// ZonedDateTime currentTimestamp = ZonedDateTime.now(); + + return book; + } + + public static Author createAuthor(String authorName) { + Author author = new Author(); + author.setName(authorName); + return author; + } + + public static BookDetails createBookDetails(String isbn, int pageCount, Book book, Author author) { + BookDetails bookDetails = new BookDetails(); + + bookDetails.setAuthor(author); + bookDetails.setBook(book); + bookDetails.setIsbn(isbn); + bookDetails.setPageCount(pageCount); + return bookDetails; + } + // ======================== END of INSERTing ================================= +} diff --git a/projekt_2/src/main/java/org/example/Review.java b/projekt_2/src/main/java/org/example/Review.java new file mode 100644 index 0000000..cb86518 --- /dev/null +++ b/projekt_2/src/main/java/org/example/Review.java @@ -0,0 +1,79 @@ +package org.example; + +import jakarta.persistence.*; + +@Entity +@Table(name = "reviews") +public class Review { + +@Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "review_id") + private Long id; + + @ManyToOne + @JoinColumn(name = "book_id") + private Book book; + + private int rating; + + @Column(name = "review_text", columnDefinition = "TEXT") + private String reviewText; + + @Column(name = "author_name") + private String authorName; + + public Review() { + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Book getBook() { + return book; + } + + public void setBook(Book book) { + this.book = book; + } + + public int getRating() { + return rating; + } + + public void setRating(int rating) { + this.rating = rating; + } + + public String getReviewText() { + return reviewText; + } + + public void setReviewText(String reviewText) { + this.reviewText = reviewText; + } + + public String getAuthorName() { + return authorName; + } + + public void setAuthorName(String authorName) { + this.authorName = authorName; + } + + @Override + public String toString() { + return "Review{" + + "id=" + id + + ", book=" + book + + ", rating=" + rating + + ", reviewText='" + reviewText + + ", authorName='" + authorName + + '}'; + } +} diff --git a/projekt_2/src/main/resources/hibernate.cfg.xml b/projekt_2/src/main/resources/hibernate.cfg.xml new file mode 100644 index 0000000..f75a858 --- /dev/null +++ b/projekt_2/src/main/resources/hibernate.cfg.xml @@ -0,0 +1,23 @@ + + + + org.postgresql.Driver + jdbc:postgresql://localhost:5432/pra_db + devuser + admin + + Europe/Warsaw + + + + org.hibernate.dialect.PostgreSQLDialect + true + update + + + + + + + + \ No newline at end of file diff --git a/projekt_2/start.sh b/projekt_2/start.sh new file mode 100755 index 0000000..f3f5360 --- /dev/null +++ b/projekt_2/start.sh @@ -0,0 +1,18 @@ +#!/bin/bash +CONTAINER_NAME="pra-db" +SQL_FILE="init_db.sql" + +docker-compose up -d + +# Copy the SQL file to the container +docker cp $SQL_FILE $CONTAINER_NAME:/init_db.sql + +# Wait until the PostgreSQL server is ready +echo "Waiting for PostgreSQL to become available..." +until docker exec $CONTAINER_NAME pg_isready -U devuser -d pra_db > /dev/null 2>&1; do + sleep 1 +done +echo "PostgreSQL is available now." + +# Execute the SQL file inside the container +docker exec -it $CONTAINER_NAME sh -c "psql -U devuser -d pra_db -f /init_db.sql" diff --git a/projekt_2/target/classes/hibernate.cfg.xml b/projekt_2/target/classes/hibernate.cfg.xml new file mode 100644 index 0000000..f75a858 --- /dev/null +++ b/projekt_2/target/classes/hibernate.cfg.xml @@ -0,0 +1,23 @@ + + + + org.postgresql.Driver + jdbc:postgresql://localhost:5432/pra_db + devuser + admin + + Europe/Warsaw + + + + org.hibernate.dialect.PostgreSQLDialect + true + update + + + + + + + + \ No newline at end of file diff --git a/projekt_2/target/classes/org/example/Author.class b/projekt_2/target/classes/org/example/Author.class new file mode 100644 index 0000000..3d99639 Binary files /dev/null and b/projekt_2/target/classes/org/example/Author.class differ diff --git a/projekt_2/target/classes/org/example/Book.class b/projekt_2/target/classes/org/example/Book.class new file mode 100644 index 0000000..7b16ff8 Binary files /dev/null and b/projekt_2/target/classes/org/example/Book.class differ diff --git a/projekt_2/target/classes/org/example/BookDetails.class b/projekt_2/target/classes/org/example/BookDetails.class new file mode 100644 index 0000000..0269130 Binary files /dev/null and b/projekt_2/target/classes/org/example/BookDetails.class differ diff --git a/projekt_2/target/classes/org/example/Main.class b/projekt_2/target/classes/org/example/Main.class new file mode 100644 index 0000000..5810a99 Binary files /dev/null and b/projekt_2/target/classes/org/example/Main.class differ diff --git a/projekt_2/target/classes/org/example/MyQuery.class b/projekt_2/target/classes/org/example/MyQuery.class new file mode 100644 index 0000000..7c54eb2 Binary files /dev/null and b/projekt_2/target/classes/org/example/MyQuery.class differ diff --git a/projekt_2/target/classes/org/example/Review.class b/projekt_2/target/classes/org/example/Review.class new file mode 100644 index 0000000..7c471ae Binary files /dev/null and b/projekt_2/target/classes/org/example/Review.class differ