Manage table relationships in Java dynamic web application that accesses a database, without using any framework

I’m developing a web application for academic purposes.
What i have to do is a simple website which keeps track of realties along with their respective owners and the tags they are bound to.

The application takes data from a MySQL database and must include the following features:

  • List all realties
  • List all realties with a specific tag
  • List all realties owned by a specific owner entity
  • List all realties owned by a specific owner and with a specific tag

It is required to use JDBC to connect to the database, JSP/Servlet to create the dynamic pages, (optionally) Java Beans to display properties (either using useBean or JSTL/EL) and no frameworks. Everything must be done in pure Java.

It is not a complex application, and it being just for academic purposes also means that i do not have to keep in consideration any scalability issue. I could simply put the code for the database connectivity and queries in the JSP page as a scriptlet and call it a day.

However, what i really want to do is to follow the MVC pattern and learn to make tidy code.

This is the approach i’d like to follow:

  • The JSP pages shape the view layer, only containing HTML and JSTL to access the model
  • The model consists of the Java Beans. Each JB represents a table with its respective columns
  • Servlets make the controller layer. They call methods from Service classes containing database queries and send the resulting Java Beans in the view layer by dispatching the request to a JSP.

This is how i structured the tables:

Realties ----------------- (pk) id surface_area rooms_number year price (fk) owner  Owners ----------------- (pk) id name surname  Tags ----------------- (pk) id title     realties_xref_tags ----------------- (pk)(fk) realty_id (pk)(fk) tag_id   

There is a many-to-one relationship between the realties and the owners table and a many-to-many relationship between the realties and the tags table (A realty can have a list of tags)

These are the Beans, one for each table except for realties_xref_tags. (Getters and setters are omitted)

public class Realty implements Serializable {      private BigInteger id;     private double surface_area;     private int rooms_number;     private int year;     private BigDecimal price;     private BigInteger owner_id; }  public class Owner implements Serializable {      private BigInteger id;     private String name;     private String surname; }  public class Tag implements Serializable {      private BigInteger id;     private String title; } 

Here, i am having troubles trying to find out the best way of managing relationships.

  • Should the Realty bean keep track of its owner with a field holding the foreign key, or should it hold a reference to an actual Owner object corresponding to that foreign key? I understand the latter choice may not be optimal with a big number of attributes or entries.
  • How to avoid instantiating duplicate Beans for the same Owner entity? Consider a scenario where there are 10 realties and 4 owners. There would be realties which have the same owner, but the application would still end up instantiating 10 Owner beans when trying to fetch all entries
  • Should i just make a List<String> field for tags in the Realties class?

Which approach should i take to handle relationships in DTOs so that it results in good practice in a (small) real-world project scenario?

How to build an execution graph of concurrency accesses

Sorry If I don’t use the right vocabulary, maybe part of my question is due to the fact that I don’t know the name of what I’m searching.

I have a bounded set of operations that need to access a database. I want to create an “execution graph” of these operations that prevents conflicting accesses. For each of this operations, I know the read set and write set.

Let’s say I have four operation, a, b, c and d :

readSet(a) = {k1, k2} writeSet(a) = {}

readSet(b) = {} writeSet(b) = {k1}

readSet(c) = {} writeSet(c) = {k2}

readSet(d) = {} writeSet(d) = {}

So here I can build the graphs whit the following set of edges :

g1 -> { (b, a), (c, a) }

g2 -> { (a, b), (a, c) }

How do I build such a graph that is that is as little deep as possible ? ( i.e that maximize the parallelism ? )

What are the keywords to find litterature on this problem ?

Mark Link which blocks accesses from the EU because of the GDPR

I run a site for visitors from Germany who would like to visit the USA. Because of the GDPR more and more websites in the US block access from the EU like the LA Times, IHOP or Carrabbas. The access within the US, so if visitors are on site is of course possible, so the link should remain.
Blocked pages do not always give clear hints why an access is blocked, eg. only a 403 or 451 error page without any info why.
How can I best mark such a link?

On the desktop version, I linethrough the link blue and use the title attribute so that the mouse over an info text is displayed. (I know the title attribute should be used differently, it will soon be replaced by CSS Over). However, this is not possible on a mobile phone.

Since many pages are static, I do not want a solution based on the visitors IP works.
Also, it does not make sense for me to work with a symbol and a symbol explanation in the footer, because on a mobile device no one scroll down to read the explanation.

Do you have any idea how to label a link that says, “Hey, I’m locked in the EU and can only be access in the US?” on a mobil device.

How to track network file share accesses on workstations

I shared a folder created in my C drive with a colleague over the network and he was able to access it. Is there any log that will track this kind of activity? I am aware of Windows Security Event ID 5140: A network share object was accessed. Should this be on the workstation or will there be an AD authentication to the Domain controller to verify the person accessing it is actually the person whi is given permissions. Any thoughts will be appreciated.

How to fix the “Overlapping accesses to ‘self’, but modification requires exclusive access; consider copying to a local variable” error in my code?

I can’t continue with my app and I can’t test run it because something is wrong in my code that I don’t know how to fix! Here is the code:

import Foundation  extension Array {     mutating func shuffle() {         if count < 2 { return }         for i in 0..<(count - 1) {             let j = Int(arc4random_uniform(UInt32(count - i))) + i              customSwap(a: &self[i], b: &self[j])         }     } }  func customSwap<T>(a:inout T, b:inout T) {     let temp = a     a = b     b = temp }