Summary of the invention
The present invention proposes a kind of association and mapped system of multiple entity, can correspondingly be mapped to different objects in the virtual world to entities different in the real world, and according to the pass in the real world tie up to set up between these objects related.
According to the present invention, a kind of association and mapped system of multiple entity proposed, comprise view layer, Business Logic and data service layer:
Described view layer provides interactive interface, shows the association of described multiple entity and the result of mapped system;
Described Business Logic comprises network layer, service layer, DAO layer and persistence object layer; Described network layer is used for the mutual of described view layer and Business Logic as controller, the calling of the service logic of control Business Logic, and for the data access of data service layer; Described service layer is used to realize the service logic of Business Logic, and the operational approach of data access object layer is carried out abstract or called, and isolates described network layer directly calling data access object layer; Described DAO layer is used for the persistence object layer mutual, and the operation of data is encapsulated; The persistence object layer, data map in the relevant database that data service layer is provided becomes object, wherein, described persistence object layer provides three class objects: first kind entity object, the second class entity object and the 3rd class entity object, there is the incidence relation of one-to-many in the incidence relation that wherein has one-to-many between the 3rd class entity object and the first kind entity object between the first kind entity object and the second class entity object; This first kind entity object can be operated and visit to the 3rd class entity object, and the 3rd class entity object can be operated this second class entity object;
Described data service layer provides relevant database, and will be kept in the described relevant database by the data that Business Logic carries out access.
Wherein, the 3rd class entity object comprises the operation of first kind entity object: the 3rd class entity object adds a first kind entity object, and wherein this first kind entity object is related with the 3rd class entity object; The 3rd class entity object comprises the visit of first kind entity object: the 3rd class entity object is checked a first kind entity object, and wherein this first kind entity object is related with another the 3rd class entity object; Perhaps the 3rd class entity object is checked a first kind entity object, wherein this first kind entity object the 3rd class entity object association.
The 3rd class entity object comprises the operation of the second class entity object: the 3rd class entity object adds one second class entity object, wherein this second class entity object is related with the 3rd class entity object, and, this second class entity object is related with a first kind entity object, and this first kind entity object is related with another the 3rd class entity object.
The relevant database of described data service layer comprises three data classification: user data class, product data class and behavioral data class, and wherein first kind entity object shines upon generation from the data of product data class; Mapping produces in the data of the second class entity object subordinate act data class; The 3rd class entity object shines upon generation from the data of user data class.
Adopt technical scheme of the present invention, realized user, article and the behavior mapping in virtual world well, the system that utilizes the present invention to propose can realize relating in the simulating reality world network auction system of above-mentioned three kinds of things.
Embodiment
At first with reference to figure 1, the present invention proposes a kind of association and mapped system of multiple entity, comprises view layer 10, Business Logic 20 and data service layer 30:
View layer 10 provides interactive interface, shows the association of multiple entity and the result of mapped system.In one implementation, view layer 10 can be realized (JSP and Struts1.2 tag library all are the common technologies in this area, are not described in detail) herein by JSP and Struts1.2 tag library.View layer 10 is mainly used in user interactions and result and represents to the user, and view layer 10 can be showed dynamic web page or static Web page.From user perspective, no matter be dynamic web page or static Web page, can show basic literal and pictorial information, but very big difference just be arranged from the angle of Website development, management, maintenance.Dynamic web page is preferable selection, because dynamic web page is based on database technology, carries out relevant calling based on database, can reduce programmer's workload greatly aspect website maintenance.Another advantage of dynamic web page is, uses the website of dynamic web page technique can realize more function, as user's registration, user's login, online auction, user management, order management or the like.Dynamic web page is not the web page files that is present in long since on the server in addition, but the complete webpage that the request by the user just makes server return.Business Logic 20 further comprises network layer 21, service layer 22, DAO layer 23 and persistence object layer 24.
Network layer 21 is used for the mutual of view layer 10 and Business Logic 20 as controller, the calling of the service logic of control Business Logic 20, and for the data access of data service layer 30.Network layer 21 is also referred to as the Web layer, and effect is equivalent to controller.In one implementation, the ActionServlet and the Action of network layer utilization Struts1.2 framework control forwarding, and main effect is the business procedure of describing in the application program, calls corresponding Struts1.2 framework and carries out result's control.Service layer 22 is used to realize the service logic of Business Logic 20, the operational approach of data access object layer 23 is carried out abstract or is called, directly the calling of 21 pairs of data access object of isolation network layer layer 23.Service layer 22 is also referred to as the Service layer, is the layer of being responsible for realizing service logic.The Service layer carries out the encapsulation of face model to the object in the data access object layer.The operational approach of data access object layer is carried out abstract or called, isolate the Web layer to directly the calling of data access object layer, strengthen the low coupling of high polymerization with this.Can not produce any influence even change the method for DAO layer to the Web layer yet.
DAO layer 23 is used for the persistence object layer mutual, and the operation of data is encapsulated.DAO layer 23 is also referred to as the DAO layer, and the DAO layer is responsible for the persistence object layer mutual, has encapsulated the operation of data.In one implementation, the BeanFactory mechanism of DAO layer utilization Spring2.0 is carried out the instantiation of bottom class, and carries out the corresponding database operation by the Hibernate framework.The DAO layer is a Data Access Object data access interface, so name Si Yi comes into contacts with database exactly.The DAO layer is used for encapsulation of data source Data Source, just can use getConnection () method in the Facory object to change the type of database by encapsulation, such as changing MSSQL into Oracle.Another characteristics of DAO layer are that it can all be encapsulated in the basic operation (CRUD) to database in the DAO layer.Such as adding new article, it is just passable only need to call an addItem (Item item) method to the DAO layer in the Service layer, and concrete realization then is to carry out in the DAO layer.When for the Service layer, calling the DAO layer method, only need know that addItem (Item item) is used for adding new article, and not need to know the DAO layer specifically is how to realize this function.
Data map in the relevant database that persistence object layer 24 provides data service layer 30 becomes object, wherein, persistence object layer 24 provides three class objects: first kind entity object, the second class entity object and the 3rd class entity object, there is the incidence relation of one-to-many in the incidence relation that wherein has one-to-many between the 3rd class entity object and the first kind entity object between the first kind entity object and the second class entity object; This first kind entity object can be operated and visit to the 3rd class entity object, and the 3rd class entity object can be operated this second class entity object.The persistence object layer is also referred to as the POJO layer, and the persistence object layer becomes object by entity/relationship map instrument with the data map of relevant database, and in one implementation, the persistence object layer adopts the Hibernate framework.In persistence object layer 24, come encapsulated object by add setter and getter method for the persistence object, make things convenient for allocating object, accomplish to deposit at any time attribute with reading object.Object after encapsulating can only come by other object accesses by shielded interface.The POJO layer is the OO performance of JAVA, and it can all encapsulate all properties of an object, stores by object and reads attribute.Because some thing is privately owned, encapsulation is exactly all attributes to be pinned do not check to the outside.And the main meaning of encapsulation is the attribute privatization with object, by revising the observability of attribute, limits visit and modification to attribute, uses for other classes.To introduce in the back relevant for the association between the three class entity objects in the persistence object layer.
Data service layer 30 provides relevant database, and will be kept in the relevant database by the data that Business Logic carries out access.
In conjunction with Fig. 2-Fig. 4, can understand the incidence relation between the three above-mentioned class entity objects.Sum up, the 3rd class entity object comprises the operation of first kind entity object: the 3rd class entity object adds a first kind entity object, and wherein this first kind entity object is related with the 3rd class entity object.The 3rd class entity object comprises the visit of first kind entity object: the 3rd class entity object is checked a first kind entity object, and wherein this first kind entity object is related with another the 3rd class entity object; Perhaps the 3rd class entity object is checked a first kind entity object, wherein this first kind entity object the 3rd class entity object association.
And the 3rd class entity object comprises the operation of the second class entity object: the 3rd class entity object adds one second class entity object, wherein this second class entity object is related with the 3rd class entity object, and, this second class entity object is related with a first kind entity object, and this first kind entity object is related with another the 3rd class entity object.
In one implementation, for example with reference to shown in Figure 2, the relevant database of data service layer comprises three data classification: user data class, product data class and behavioral data class, and wherein first kind entity object shines upon generation from the data of product data class; Mapping produces in the data of the second class entity object subordinate act data class; The 3rd class entity object shines upon generation from the data of user data class.
Being that example describes based on the association of multiple entity of the present invention and the auction system of mapped system, data map in the user data class produces first kind entity object, can be understood as a user of this system, the user can carry out following operation after login system: add one's own auction items, browse other people auction items, auction items that browse oneself or that oneself is won back, own interested article bidded or the like.
As described above, wherein first kind entity object shines upon generation, so article are corresponding to the second class entity object from the data of product data class.The user comprises the operation that article can carry out:
Add one's own auction items, this situation promptly is that the 3rd class entity object adds a first kind entity object, wherein this first kind entity object is related with the 3rd class entity object, because this auction items is one's own, so these article are associated in this user.
Browse other people auction items, this situation promptly is that the 3rd class entity object is checked a first kind entity object, and wherein this first kind entity object is related with another the 3rd class entity object.Because what check is others' article, and herein others must be another user in this system, and therefore in fact these article are associated with another user.
The auction items of browsing oneself or oneself is won back, promptly the 3rd class entity object is checked a first kind entity object, wherein this first kind entity object the 3rd class entity object association.Since these article have by inch of candle been won back or originally oneself, so these article belong to this user, be associated with this user.
A user can have several article, and article can not belong to a plurality of users simultaneously, so, between user and the article a kind of relation of one-to-many, promptly there is the incidence relation of one-to-many between the 3rd class entity object and the first kind entity object.
Fig. 3 has introduced user and article, i.e. incidence relation between first kind entity object and the 3rd class entity object.
Next in Fig. 4, introduce user and behavior, i.e. incidence relation between the second class entity object and the 3rd class entity object.
In the example of auction system, the user need bid to others' auction items, promptly the 3rd class entity object adds one second class entity object, wherein this second class entity object is related with the 3rd class entity object, this second class entity object is related with a first kind entity object, and this first kind entity object is related with another the 3rd class entity object.When the user bids, be to carry out at not one's own article, therefore, these article are actually with another user and are associated, and must be to propose at some article and bid, and therefore bidding is to be associated with article.For article, different bidding can be proposed by different users, therefore article are to be associated with a plurality of bidding, and promptly have the incidence relation of one-to-many between the first kind entity object and the second class entity object.Each is bidded is to be proposed by user, so this is bidded and is to be associated with corresponding user.In one implementation, the second class entity object can also comprise two subobjects, and first subobject is with relevant at the behavior of corresponding first kind entity object, and second subobject is relevant with the behavior of the 3rd corresponding class entity object.For example, for each article, its history is bidded record as first subobject, comprising all at the bidding of this article, and some users can repeatedly bid to these article, all and this user-dependent bidding as second subobject.
Introduced the association that utilizes multiple entity of the present invention and an application example of mapped system in conjunction with auction system above, but it will be appreciated that the association of multiple entity of the present invention and the application of mapped system not only are limited in auction system.
Adopt technical scheme of the present invention, realized user, article and the behavior mapping in virtual world well, the system that utilizes the present invention to propose can realize relating in the simulating reality world network auction system of above-mentioned three kinds of things.