Design of account e-mail activation (with Hibernate in mind) -
I have a design problem on which I need some input. These are the obstacles:
- When registering your account, each user must have an e-mail address. An activation email should be sent when registering your user account, which has a link with an activation code, which should be done to activate the account.
- Every user account is exactly one company that is exactly one company.
- The company's registered company creates the company and an office. Companies can interact with each other, but only if companies can activate first users (i.e. they have clicked on their respective activation link after registration).
This is a small UML-diagram of how it can be resolved:
Some details were left in the picture given above The diagram shows only sections and areas when it comes to the field, then they just show the concepts that what information should be stored, please ignore their scope.
Some thoughts and questions:
- Users and noteded users are mostly the same or are they different in the same class? If they separate, in what form will you use the persistence of inheritance in hibernation?
- If an account is not activated after a certain time, then it should be removed. If it was the first user who created users too, both the company and the office should be removed. Do we also need a notteactive office and a noteworthy company? (For clean segregation in the database.)
How would you design such a solution? Is it important to keep non-active and active entities separate in the database? Why not and why not?
I do not use legacy to represent a state (active / inactive) User Objects Structure (Aggregation) Here's a better option.
Using aggregation, ABETUUSER becomes the user only. Instead of polluting the user class with activation related attributes, you want to model activation with one class. In this way you get a nice and clean object model.
At the database level, you can still decide to store two objects in the same table / record, which is known. Or you can decide to store user and activation in different tables (aka).
Hibernation supports both types of mapping, it is a matter of mostly configurations.
The user class has the following attributes:
- The givenName
- < Activation class will have the following attributes:
- Activation code (string)
- Sent (when email was sent)
- / Li>
- activated (default for blank, set to current date / time when user
you have at least one active user: at least one You can use a HQL query to find out which user is a user:
This question assumes that you have an administrator in your admin The Office Class 'Administrator' will have a reference to the user who has created the office. In the database, a user in the 'Office' table is a foreign key for the record.
The relationship between modeling in this manner A , You can change an office administrator (for example, he was fired from leaving office or office / company). It all depends on your use cases ...
I also added an attachment for the activation class used to clear the inactive account after some time (disappeared in your UML diagram was not).
Comments
Post a Comment