Transformation of Russian reporting using Excel. What is mapping

Problem

You have downloaded a cost accounting report and want to show it to management. To do this, you need to compile the data from accounting items - according to management accounting items. You know how accounting and accounting articles relate to each other, but each time preparing such a report manually takes you too much time.

Solution

We will consider this case as a continuation of the previous one. Let's imagine that you created the following directory in Excel:

Fig.2.1. Directory: mapping of BU and CU articles


On the left is a cost item (AC), on the right is a management accounting item (MA). It is important that the cost item appears only once in the first column, otherwise the mapping mechanism will not work correctly.

(By the way, the English word mapping is translated as display or correspondence, so the reference book in in this case- this is something general rule how BU articles are reflected in OU articles).

Fig.2.2. Flat table: cost report (from "Account turnover 20")


Please note that in the 7th column the column “Article TC” has appeared. Opposite each cost item we have placed a management accounting item. This can be done manually, but it is much more convenient to use this tool:

Fig.2.3. Flat table: cost report (from "Account turnover 20")


At the bottom of the form are the names of the pages: “Home” is a flat table that contains cost data (Fig. 2.2), “spr” is a reference book (Fig. 2.1).

The column numbers are indicated at the top of the form. So, in this case, if the data in columns 1 of the directory and 3 of the main page coincide, then the data from the 2nd column of the directory is copied to the 7th column of the main page.

This form also has many additional options. For example, you can enable the “Feature #2” and “Feature #3” checkboxes, and then transferring data from column 2 of the directory to column 7 of the main page will be possible if the directory and home page I will match two or even three details at once.

As a result of such a simple operation, using a pivot table, you can build a number of different analytical reports, in which one of the sections will include the analytics “Article OU”. For example, like this:

Fig.2.4. Cost report for reinforcement shop


Comparison of mapping with VLOOKUP()

Many users are familiar with and use the VLOOKUP() function in these types of situations. However VLOOKUP function() works well only on small volumes data, while this form copes well with processing Excel tables, even if you have, say, 5,000 rows in the reference book, and 300,000 rows on the goav page. Try checking it and you will see that VLOOKUP() fails at such volumes. In addition, the VLOOKUP() function creates a significant load on Excel, forcing it to carry out large amounts of calculations. The mapping form avoids this drawback: it runs once, lasts for a few seconds (for large volumes of minutes) and after that there is no additional load on Excel file is no longer created.

Have you heard of mapping? In Russian transcription it is mapping, mapping. The concept has several meanings that are not related to each other. Let's look at each of them in the context of the area where they are relevant.

What does the concept mean in general?

Mapping, mapping, mapping, mapping is the determination of the correspondence of information between two different semantics of one object or several. In other words, this is the name for converting data from one form to another.

What is mapping? In its general meaning, the term is quite broad - it can be either a scrupulous transformation of one sequence of elements into another, or normal conversion currency, files. Thus, everything that is hidden under the term being analyzed is best expressed by the English-language concept of data mapping.

Mapping examples

Let's look at what mapping is using the following examples:

  • Drawing up a document of correspondence of accounting accounts from their various plans. For example, Russian, IFRS, management accounting, etc.
  • Translation of database codes from one system to another. For example, we need to convert the designations 0 and 1 into “no” and “yes”.
  • Converting dollars to euros is some kind of mapping.
  • Changing the format of an image from .png to .jpg, a movie from .avi to .mp4, carried out in a graphic or video editor, will in some way relate to the subject of our conversation.

Computer game development

Mapping (from English. map- "terrain map") can also be used in the meaning of level design. This is the name given to the discipline of video game development. This is, first of all, the creation of levels of varying complexity - elaboration of the player’s mission, location design, composing tasks, etc. In practice, such activities are carried out in the “levels” editor.

Mapping technologies here are heterogeneous - it all depends on the developers’ budget, character, genre created game. Let's look at a classic example to have a better understanding of the concept:

  • Creating a map of the territory and dividing it into zones - cities, mountain ranges, underground tunnels, forests, etc.
  • Definition of regions associated with some specific activity of the player - a battlefield, a store for additional attributes, resource extraction, fortifications, a resting place, a board of honor, etc.
  • Development of non-static objects. They can be keys, doors, secret buttons and passages, disappearing secret passages, etc.
  • Identification of important locations of organizations - this is a recovery point, treasures, treasures, caches with secret weapon and so on.
  • Establishing the start and finish location of movements for each player.
  • Bringing the map to life with a number of details: adding elements such as textures, sounds, audio, visual effects, illusions, animations, etc.
  • Inserting the necessary triggers (mechanisms that check the presence of any object in the created game space) and scripts (scenarios, short algorithms of actions).
  • Creation of certain scripts for the movement of mobs (non-static objects, characters): zones where they can move, their interaction, dialogue with the player, etc.
  • Sometimes includes the creation of cut scenes - beautiful screensaver, a mini-movie, a kind of trailer for a game or level, a group of “levels” that the gamer can only view, but in no way influence what happens in it.

Video mapping

What is video mapping (3D mapping)? This is an amazing technology that allows you to project images, specially created films onto large-scale uneven surfaces, for example, onto the facades of buildings.

The uniqueness of this is that it allows you to “revive” houses and other interior items by giving them visual mobility. And everything is achieved only by projectors installed according to a certain plan. The “magic” of moving three-dimensional images lies in the super-precise correspondence between the elements on which the picture is reflected and the video projection itself.

Although for many of us mapping is a fairly new direction, it was born back in the sixties of the last century. We owe its appearance to Walt Disney and the Disney studio. Then the working name of mapping was “shade lamps”, “space virtual reality"The first show is considered to be the Haunted Manor attraction at Disneyland. For it, artificial severed heads were created, onto which an image was projected, “revitalizing” them.

What can video mapping be like?

Depending on the object on which the image is reflected, the technology is divided into several areas:

  • Architectural. Volumetric projection on complex object- facade of a building, bridge, tower, as well as on an airplane, ship, etc.
  • Interior. Creating interesting illusory solutions indoors by projecting pictures onto the walls, ceiling, floor.
  • For small objects. Both small forms and elements of something larger are used. For example, car wheels, cake, bride's dress, etc.
  • Landscaping. The basis is forests, mountains and other natural objects.
  • Interactive. The newest direction excellent theme that here a person becomes a hero. Technology brings objects around the artist to life, helping him create an unforgettable show.

Where is 3D mapping used?

Let's see where this technology may be relevant:

  • creating volume on various surfaces;
  • city ​​holidays, public events;
  • major corporate events;
  • opening of shopping centers, entertainment complexes;
  • children holidays;
  • cultural, historical, educational events.

This show looks most impressive in the dark. To give a more striking effect, the organizers combine it with a suitable volumetric sound sound, live music, fireworks.

If you want to get acquainted with reviews of technology, then just listen to those who have at least once visited the Moscow Circle of Light. Recently, this festival, which attracts thousands of spectators, takes place every autumn in the capital. Designers from different countries create video projections that are shown on the facade Bolshoi Theater, the main pavilion of VDNH, the main building of Moscow State University, etc.

Mapping is a multi-valued concept. This includes complex data conversion and creation of locations in computer games, and a show based on projecting images onto large and small objects.

Dozens of words come into the Russian language every year, settle in it and hurt our ears. Anglicisms are used inappropriately and out of place, terms lose their meaning original meaning and move to new areas, and long-familiar words suddenly appear in an unfamiliar context - it’s easy to get confused. Strelka magazine is putting things in order in the Vocabulary section.

Where did it come from?

The word is derived from the English “map” and the suffix -ing attached to it. Literal translation - mapping, mapping and topographic survey. IN Lately"mapping" is used in a broader sense, going beyond the purely topographical topic.

What is written in the dictionary

"Mapping - graphical representation procedure, process, structure or system that reflects the arrangement or relationships of components, and also documents flows, for example, money, energy, goods, information, migration." (businessdictionary.com)

“Video mapping - also used to mean 3D mapping - a direction in audiovisual art, which is a 3D projection onto a physical object environment taking into account its geometry and location in space.” (projection-mapping.org)

In the meaning of “visualization” - “a method of presenting information in the form optical image(for example, in the form of drawings and photographs, graphs, diagrams, block diagrams, tables, maps, etc.). It is very effectively used to present initially non-visual information (for example, temperature, population density, distribution of levels of electromagnetic fields, etc.)" (Dictionary of business terms. "Akademik.ru". 2001)

“Mind mapping is a graphic technique that is based on the use of the brain’s natural tendency to think associatively, from the center to the periphery.” (mind-mapping.co.uk)

What the experts say

Kuba Snopek, teacher at the Strelka Institute, talks about mapping as a tool for studying the city

“I don’t call mapping cartography because cartography is a recognized scientific discipline, and it implies a very clear method. In short: a person goes to a new place and attacks everything he sees.

The mapping that we use as a tool for studying the city at Strelka is different and implies a reflection of the processes taking place in the city. We create a map on top of the existing one and check what has changed since the geodetic base was created. And each researcher can get his own map of the same space. This is the most interesting part: one can look only at architecture, another at the behavior of people, a third at the behavior of animals or at the light spectrum.

For me, any project starts with a map. Without this it is impossible to move on. Currently I am doing a project related to Polish churches. There is a map of four thousand objects, and the analysis of this map is the most important part of the project, it is its main document.”

Alexey Rozov, co-founder of the Power of Light company, talks about 3D mapping

“The point of 3D mapping is that we create a picture that is superimposed on a physical object in accordance with its shape and architecture. This is what makes it possible to modify a building using 3D transformation or changing textures.

First, engineers make a 3D model of the building. If the design is not very complex, then a model can be made by going to the territory and taking dimensions. If this is, for example, the Bolshoi Theater, then laser scanning is done, and a model is created from the resulting cloud of points.

Terrestrial 3D laser scanning of facades / photo: severnpartnership.com

Animators-artists then use 3D modeling programs to create the content. While they are drawing, engineers are making calculations about how many projectors and how much power are needed to cover the surface of the building. For example, the Bolshoi Theater needs 12 projectors, the Manege - eight, and the Moscow State University - 86. Calculations are also made on the brightness and resolution of the picture. Then a virtual set-up - setting up all the projectors so that they form a single picture. When the content is ready, everyone goes directly to the site. The projector tower is assembled on site and installed required servers, and engineers begin to flatten the image so that it falls squarely on the building. The computer turns on with the content loaded and the show begins. There shouldn't be any mistakes. If only very small ones, invisible to the average viewer. I've seen bad examples where people wanted to do 3D mapping, but the graphics turned out to be ugly, the projection didn't hit the object very accurately, the light coming out of the projector was miscalculated - and it turns out that everything looks dim, the image is pixelated, and it does not decorate, but, on the contrary, only spoils.

The time spent on one project depends on the scale of the building and the length of the video. If, for example, you are making a show for Moscow State University for half an hour, then, in good terms, you need a year to create it, and if for the Bolshoi Theater it is three minutes long, a month or two is enough for you.

It is difficult to say how developed this is in Russia compared to other countries, but, for example, Moscow hosts the powerful annual Circle of Light festival. Today there is a tendency to use 3D mapping as interior design: permanent basis in a museum or mall they put on a show for guests several times a day.”

Usage examples

“Mapping reveals the economic, cultural and political value of the information that space provides. The method allows you to combine all this information and link it to a specific place.” (Strelka Magazine)

“For the 125th anniversary, the Czech Academy of Sciences prepared a visual show - video mapping on its historical building in Prague.” (420on.cz)

“Mind mapping is translated into Russian as “thinking map”, “mind map”, “memory map”, “ mental maps“. The visualization method can be used to create new ideas, analyze and organize information, take notes, make decisions and much more.” ("Science and life")

Companies that use Excel for reporting transformation purposes receive tangible savings when preparing financial statements under IFRS. If transaction volumes allow credentials to be processed in spreadsheets, it is advisable to use Excel

12.01.2016

Excel tables, in addition to arithmetic accuracy and clarity of transformation procedures, make it possible to generate data for economic analysis of financial activities based on IFRS results, which turns the reporting model into a management tool.

Preparatory stage of reporting transformation

On preparatory stage an analysis of specific differences between IFRS applicable to a given company and accounting practices under RAS is carried out. It should be noted that it is inappropriate to start from the rules of Russian accounting, since in this case it will be difficult to get away from the “priority of form over content” - you should start with an analysis of the company as a whole and its activities from the point of view of IFRS.

International standards relevant to each specific business should be included in accounting policy according to IFRS. For example, a trader is unlikely to use complex financial instruments or the provisions of IAS 41 " Agriculture” and a private company does not have to disclose earnings per share in accordance with IAS 33 Earnings per Share. The procedure for developing an accounting policy should be aimed not only at creating accounting rules and memorandums in accordance with IFRS, but also at preparing a block of notes directly to the IFRS statements, containing the main aspects of the accounting policy required to be disclosed in accordance with IAS 1 “Presentation financial statements".

Based on the obtained accounting policies under IFRS, it is necessary to identify discrepancies in the estimates and principles applied in RAS, and create a list and rules for calculating the main transformation adjustments, as well as a list additional information, necessary for the purposes of IFRS, but not taken into account in accordance with the requirements of Russian legislation.

On first use international standards In accordance with IFRS 1, you should be aware of the exceptions and simplifications allowed by the standard, and that these reliefs no longer apply.

The process of updating accounting policies under IFRS, the list of adjustments and the list of additional information must be constant, since the requirements of IFRS and Russian legislation are constantly being updated.

Chart of accounts mapping for reporting transformation

Mapping - from the English mapping (correspondence, as well as transformation) - is a procedure for posting data in several coordinate systems, in our case, converting balances and turnover generated in accordance with the RAS chart of accounts into the structure of the chart of accounts according to IFRS (Table 1).

Table 1. Example of chart of accounts mapping

A few words about drawing up the actual chart of accounts according to IFRS.

  • Each IFRS indicator must have a unique digital code, in extreme cases, alphanumeric, in a strictly defined format. Summarizing indicators in modern versions Excel is possible even based on text characteristics, but in this case the risk of data distortion increases in the event of a simple typo. To minimize errors, directories and drop-down lists with codes and names of accounts and analytics are used, as well as “SUMMIF” and “VLOOKUP” formulas that summarize data with specified characteristics, namely unique codes.
  • The hierarchy of the chart of accounts should allow you to group data not only by elements, but also by lines of the reporting form and notes. Let’s say that the article “Buildings and structures - Initial cost”, in addition to its own code, should also contain among the analytics the line code of the statement of financial position (hereinafter referred to as the balance sheet) and the code of the notes table, which will allow you to fill out forms and tabular reporting notes using Excel formulas.
  • Each section of the reporting forms in the chart of accounts must contain spare empty lines- this makes it possible to flexibly adjust the chart of accounts without reconfiguring formulas, and also allows you not to violate the principle of data comparability. It is advisable to provide space for new sections, for example, if the company has not previously owned investment property, but management plans to create or acquire real estate for rental. In this case, you simply fill in the empty rows and enter reporting codes, and Excel automatically aggregates the indicators.
  • It is necessary to save the history of changes to the mapping (usually on the basis of a memorandum or other administrative methodological document) indicating the reason, the person responsible, and the timing of the changes coming into force. This is important both for generating comparable data from period to period and for passing an audit.

It should be noted that the more the analyst contains Russian plan accounts, the easier it is to carry out mapping and reclassification adjustments necessary in connection with different principles data aggregation in RAS and IFRS. Therefore, if possible, the RAS chart of accounts and its analytics should be brought as close as possible to the needs of IFRS in order to increase the efficiency of the transformation process and reduce costs.

Gathering the information necessary to fill out the transformation model. On at this stage Data on balance sheet account balances and turnover of income and expense accounts for the reporting period is collected, the initial balance sheet and profit and loss statement are filled out.

Along with this process, significant transactions, litigation, major new contracts, and additional disclosures are reviewed. A regulated list of additional information should be developed, as well as those responsible for the preparation of the relevant data should be assigned and deadlines should be established.

The list presented in Table 2 can be either shortened if the company does not have certain operations, or significantly expanded. As a rule, changes in a company's activities that entail additional adjustments to IFRS rarely occur. Therefore, the most thorough analysis is done during the initial acquaintance with the business, and only then significant changes are monitored. Thus, in most cases, companies should make about ten to twenty transformational adjustments, which can be regulated by appropriate methodological instructions and are enshrined in the document “Procedure for accounting for transformational adjustments”.

Table 2. Sample list of additional information

All adjustments should be made in the form of a working document similar to an accounting statement. The working document must contain methodological basis and the actual premises on the basis of which certain adjustments were made, and the calculations themselves. You also need to install control procedures aimed at checking the correctness of calculations, reconciling data from working documents and transformation models, as well as the correctness of postings.

Stage of formation of incoming adjustments. Incoming adjustments are generated when IFRS is first applied, as well as in transactions involving the acquisition of new companies, which must be measured at fair value.

To begin with, the balance sheet and profit and loss account items are regrouped. These are so-called reclassification adjustments. Major reclassification adjustments include the reversal or reversal of accounts receivable, payable and advances, the reclassification of deferred expenses, the separation of current and non-current assets and liabilities, the transfer of deposits with maturities of less than 90 days to cash, and a more detailed posting of income and expenses to related accounts if similar work was not done at the mapping stage (Table 3).

Table 3. Example of a reclassification table

The next block of adjustments is corrections that affect the amount of balance sheet items, as well as income and expenses. They should not be confused with reclassification adjustments, since only estimated adjustments affect the amount of deferred taxes under IFRS.

In practice, the most significant adjustment amounts relate to the measurement of assets at fair value - fixed assets (especially in cases where the company owns old assets) and intangible assets. It is impossible to calculate such adjustments on your own, since this requires data from an examination report conducted by a qualified appraiser. For example, without special knowledge and experience it is impossible to determine the cost client base, which, when purchasing a company, must be recognized as an intangible asset under IFRS. Only after receiving valuation data on the fair amount of original cost, degree of depreciation, remaining useful life use, registers of fixed assets and intangible assets are formed in accordance with IFRS. Accounting for fixed assets and intangible assets can be carried out either in a separate program or in spreadsheets, when a register of fixed assets is maintained in Excel, receipts, modernizations, disposals of objects are reflected, and depreciation is calculated at the cost recognized in accordance with IFRS.

The simplest way to calculate adjustments is to compare RAS and IFRS data and determine the discrepancy between them. These amounts form the amendment (Table 4).

Table 4. Calculation of adjustments for revaluation of fixed assets at fair value

In addition to reflecting the revaluation, for fixed assets and intangible assets it may be necessary to recalculate the amount of capitalized interest, since RAS and IFRS contain different approaches when determining the amount of capitalization.

The provisions of IAS 36 Impairment of Assets also focus more on testing property, plant and equipment and intangible assets, the value of which must be adjusted when there is evidence of impairment.

If a company uses finance leases in its operations (as interpreted by IFRS), the amendments may also affect the amount of property, plant and equipment and depreciation expenses, in correspondence with finance lease obligations and interest receivables for the use of loan funds.

Particular attention should be paid to adjustments related to discounting (as, for example, in the case of long-term finance leases, when both the cost of fixed assets and the debt under finance lease agreements are estimated on the basis of discounting). IFRS requires discounting of any long-term assets and liabilities:

  • the amount of revenue when payment is deferred in time;
  • the amount of a long-term reserve or provision in accordance with IAS 37 “Provisions, contingent liabilities and contingent assets”;
  • the cost of investing in a subsidiary when deferred payment for shares is provided;
  • debt component of long-term convertible bonds;
  • the recoverable amount of a financial asset accounted for at amortized cost when tested for impairment, etc.

Among the most common adjustments we can also note:

  • for inventories (writing off illiquid inventories as losses, creating a reserve for depreciation of inventories, writing off shortages and losses from damage to valuables, as well as certain types of deferred expenses);
  • for settlements with personnel (adjustments to reserves for vacations, creation of a reserve for future remuneration, settlements under pension plans);
  • Cutoff adjustments (writing off deferred revenue, additional accrual or write-off of income and expenses of the reporting period that were not reflected in RAS due to lack of documents or differences in the approach to recognizing the moment of transfer of risks and benefits, in correspondence with accounts of settlements with counterparties);
  • for accounts receivable and payable, as well as loans and borrowings (reflection at amortized cost using the effective interest method, adjustment of reserves for doubtful debts);
  • on financial investments (recognition of a share in the profit or loss of associated companies, adjustments to the value of financial investments by which the current market value can be determined, etc.).

After all estimated adjustments have been generated, the amount of deferred income tax adjustment is determined.

Of course, not all possible adjustments are listed, since the goal is to demonstrate how the pool of incoming adjustments is formed and how adjustments should be carried forward from year to year (Table 5).

Table 5. Formation of a list of incoming adjustments

Next, taking into account incoming adjustments, a balance sheet, profit and loss statement, statement of changes in capital, cash flow statement in IFRS format are prepared, and explanations for the statements are also prepared.

Primary adjustments are used to carry forward into the reporting of subsequent periods as incoming adjustments. There are two transfer methods:

  • adjustments to balance sheet accounts are taken into account in correspondence with the account of retained earnings;
  • adjustments to income/expense accounts are reversed in correspondence with the retained earnings account.

The choice of transfer method only affects the technique for calculating current adjustments for the following reporting periods, final result will be the same, but it will no longer be possible to change the model for calculating adjustments, so you should determine in advance the most convenient method and stick to it.

Stage of formation of adjustments for subsequent reporting periods. Typical adjustments in the following reporting periods must be drawn up taking into account incoming adjustments. The mechanism for generating IFRS data is as follows: Excel tables filled out page by page:

  • mapping balances and turnover according to RAS into balances and turnover according to IFRS;
  • reclassification adjustments;
  • incoming adjustments (excluding reclasses of the previous period);
  • adjustments for the current period (calculated in separate working documents taking into account accumulated incoming adjustments).

Then, using the “SUMIF” formulas, the data is pulled up onto the summary sheet (see Table 6).

Table 6. Formation of IFRS data in the transformation model

IFRS data (column 8) is obtained by summing the original RAS data, reclassifications, incoming and current adjustments. At the next stage, also using the “SUMMIF” formula, ready-made IFRS indicators are aggregated on report pages (balance sheet, profit and loss statement) by line codes of reporting forms in accordance with the assigned reporting form code (Table 7). Fill in the same way tabular forms notes, control and reconciliation formulas are prescribed between the transformation table, reporting forms and notes, the change in retained earnings for the period is compared with the opening and closing balances for the indicator (discrepancies in the amount of accrued dividends are possible).

Table 7. Example of use Excel functions"SUMMESLI"

As we can see, Excel allows you to quite simply and clearly generate IFRS data through transformation. In practice, other approaches to filling out transformation tables are also used, for example, like a classic chess set. However, if there are many adjustments, the resulting files are cumbersome and the risk of technical errors increases; moreover, it becomes difficult to analyze the amendments accumulated over several periods. Whatever the transformation model is used, there are universal recommendations for working with Excel: data storage should be organized on reliable and protected from unauthorized access servers, automatic creation backup copies main working files and auto-saving during work, regular archiving of both primary data and final models, tracking changes to files and maintaining a summary status file (checklist) containing information about the necessary stages of transformation and the degree of completion of established procedures.

Replaced classes must declare a primary key column in the database table. Most classes must also declare their own JavaBeans-style properties, including a unique entity identifier. Element in the mapping file they will define the mapping of this unique field to the table column, which acts as the primary key.

(5)

(1)

name (optional): The name of the identifier property.

(2)

type (optional): A name defining the Hibernate type of the property.

(3)

column (optional - default property name): The name of the primary key column.

(4)

unsaved-value (optional - defaults to null): An identifier property value that indicates that the instance is new (in persistent storage terms).

(5)

Distinguishes this instance from transit instances that were loaded or saved in a previous version. access (optional - defaults to property): This is the strategy Hibernate will use to access this property

object. If name attribute

is not specified, it is assumed that the class does not have an identifier property.

The unsaved-value attribute is important! If your class's default id property is not null, you must set the "unsaved-value" attribute to the appropriate value. There is an alternative announcement

to access legacy data with composite keys. We strongly discourage the use of composite keys in other cases.

5.1.4.1. generator Required child element "a defines a Java class used to generate unique identifiers for instances of pesistent classes. If necessary, the element

To pass initialization or configuration parameters for a generator instance. uid_table

next_hi_value_column

All generators implement the net.sf.hibernate.id.IdentifierGenerator interface. It's a very simple interface; many applications may use their own custom generator implementation. Despite this, Hibernate includes many built-in generators. Below are short names (labels) for the built-in generators:

Increment generates identifiers of type long, short, or int that are unique only when no other processes are adding data to the same table.

Do not use in a cluster.

identity Supports identity columns in DB2, MySQL, MS SQL Server

, Sybase and HypersonicSQL. The return identifier type is long, short, or int.

Uses a sequence in DB2, PostgreSQL, Oracle, SAP DB, McKoi or a generator in Interbase. The return identifier type is long, short, or int.

hilo

Uses the hi/lo algorithm to efficiently generate identifiers that are of type long, short or int, requiring a table and column name (by default hibernate_unique_key and next_hi, respectively) as the source of hi values. The hi/lo algorithm generates identifiers that are unique only to separate bases data. Do not use this generator for JTA connections or custom connections.

seqhilo

uses the hi/lo algorithm to generate identifiers of type long, short or int, using a database sequence.

uuid.hex

Uses a 128-bit UUID algorithm to generate string identifiers that are unique within the network (using an IP address). UUID is a 32-character string containing the hexadecimal representation of the number.

uuid.string

uses the same UUID algorithm, but the string when using this generator consists of 16 (some) ANSII characters. Do not use with PostgreSQL.

native

selects identity, sequence or hilo, depending on the capabilities of the database being used.

assigned

provides the application with the ability to independently set the object identifier before calling the save() method.

foreign

the identifier of another, associated object is used. Typically used in transactions with association by primary key.

5.1.4.2. Hi/Lo algorithm

The hilo and seqhilo generators provide two alternative implementations of the hi/lo algorithm, the preferred approach for generating identifiers. The first implementation requires a "special" table in the database to store the next "hi" value. The second implementation uses sequence (Oracle-style) in databases that support them.

hi_value next_value 100 hi_value 100

Unfortunately, you cannot use hilo when supplying your Connection to Hibernate, nor can you use it in a configuration where Hiberante uses a JTA-managed application server data source. Hiberante must be able to receive the "hi" value in a new transaction. Standard approach in EJB, is to use a session stateless bean to implement the hi/lo algorithm.

5.1.4.3. UUID Algorithm

Don't try to use uuid.string in PostgreSQL.

5.1.4.4. Sequences and identity columns

You can use the identity key generator for databases that support indentity columns (DB2, MySQL, Sybase, MS SQL). For databases that support sequences, you can use the sequence style to generate keys. Both of these strategies require two SQL queries to insert a new object into the database.

uid_sequence

To develop cross-platform applications, use the native strategy. It will use identity, sequence and hilo strategies depending on the capabilities of the database with which it is connected. this moment time Hibernate is running.

5.1.4.5. Defined IDs

If you want the application to assign IDs itself, you can use the assigned generator. This special generator uses IDs that are set by the application. To do this, the application sets the identifier to the corresponding property of the object. Be very careful when using this feature to set keys (in most cases this decision signals poor application design).

Due to its inherent nature, entities that use this generator cannot be saved via the Session.saveOrUpdate() method. Instead, you must explicitly tell Hibernate whether the object should be created or updated by calling the appropriate Session object methods: save() or update().

5.1.5. composite-id

......

For tables with composite keys, you can expose multiple class properties as object identification properties. Element accepts property mappings using child elements And .

Your persistent class must override the equals() and hashCode() methods to implement composite identifier equivalence. It must also implement the Serializable interface.

Unfortunately, the ability to specify composite identifiers implies that the persistent object is the identifier. There is no possibility for convenient processing than through the object itself. You must create a persistent class entity yourself and set its identifying property before loading() the persistent state associated with that composite identifier. We'll describe a more appropriate way, where composite identifiers are implemented as a separate class, in Section 7.4, “Components as Composite Identifiers.” The attributes that are described below are only applicable to the alternative method:

    name (optional): A component type property that contains a composite identifier (see next section).

    class (optional, by default the property type is determined through reflection): the component of this class is used as a composite identifier (see the next section).

    unsaved-value (optional, defaults to none): If set to any, this indicates that transit entities are treated as new.

5.1.6. discriminator

Element needed for polymorphic persistence using the table-per-class-hierarchy mapping strategy. This element declares a discriminator column, which is used to determine whether a table entry corresponds to a specific class in the hierarchy. The discriminator can be one of the following types: string, character, integer, byte, short, boolean, yes_no, true_false.

The corresponding discriminator column values ​​for each class are specified in the discriminator-value attribute for the elements And .

The force attribute is only useful if the table contains records with additional discriminator values ​​that do not appear in the persistent class. Typically this attribute is not used.

5.1.7. version (optional)

Element reflects that the table contains version-tagged records. This is especially useful if you plan to use long transactions(see below).

(1)

column (optional, defaults to property name): the name of the column that stores version numbers.

(2)

name: The name of the persistent class property.

(3)

type (optional, defaults to integer): The type of the version property.

(4)
(5)

unsaved-value (optional, defaults to undefined): A version property value that indicates that the entity has not yet been saved (unsaved). Do not confuse unsaved entities with transit entities that were saved or loaded in a previous session. (undefined indicates that the identifier value will be used.)

Version numbers can be of type long, integer, short, timestamp or calendar.

5.1.8. timestamp (optional)

Element indicates that the table contains records marked with a timestamp. This element acts as an alternative to version markers. Timestamps are by definition a less secure implementation of optimistic locking. However, sometimes an application uses timestamps for other purposes

(1)

column (optional, defaults to property name): The name of the column that contains the timestamp.

(2)

name: The JavaBeans-style name of the Date or Timestamp property of the persistent class.

(3)

access (optional, defaults to property): The strategy that Hibernate should use to access the value of a property.

(4)

unsaved-value (optional - defaults to null): A time property value that indicates that the entity has not yet been saved (unsaved). Do not confuse unsaved entities with transit entities that were saved or loaded in a previous session. (undefined indicates that the identifier value will be used.)

Note: element is equivalent to the element .

5.1.9. property

Element Declares a persistent, JavaBeans-style property of a class.

(1)

name: The name of the property, starting with a lowercase letter.

(2)

column (optional, property name is substituted by default): the name of the corresponding column in the database table.

(3)

type (optional): The name of the Hibernate type.

(4)

update, insert (optional, defaults to true) : indicates that the corresponding column should be included in the SQL UPDATE and/or INSERT statements. Setting both properties to false allows the value of that property to be set either from another property that is displayed in the same column/columns, via a trigger, or by another application.

(5)

formula (optional): An SQL expression that calculates the value of the property.

(6)

Calculated fields should not be mapped to a database table column.

access (optional, defaults to property): The strategy that Hibernate should use to access the value of a property.

    the value of the type property can be one of the following:

    The name of the Hibernate base type (for example, integer, string, character, date, timestamp, float, binary, serializable, object, blob).

    Java class name (for example, int, float, char, java.lang.String, java.util.Date, java.lang.Integer, java.sql.Clob).

    The name of a class derived from PersistentEnum (for example, eg.Color).

    The name of the Java class to be serialized.

The name of the custom class (for example, com.illflow.type.MyCustomType).

The access attribute allows you to control how Hibernate accesses a field at runtime. By default, Hibernate calls get/set methods to access a field. If you specify access="field" then Hibernate will bypass the get/set methods and access the field directly using reflection. You can specify your own access strategy by specifying a class that implements the net.sf.hibernate.property.PropertyAccessor interface.

5.1.10. many-to-one

A normal relationship with another persistent class is declared using the many-to-one element. In relational terms, it is a many-to-one association. It's really just a reference to an object.

(1)

name: Property name.

(2)

column (optional): Column name.

(3)

class (optional - by default, the field type is determined through reflection): The name of the associated class.

(4)

cascade (optional): Specifies which operation will cascade from the parent object to the associated object.

(5)
(6)

update, insert (optional - true by default) determines that the displayed columns will be included in SQL UPDATE and/or INSERT queries. Setting both properties to false allows the value of that property to be set either from another property that is displayed in the same column/columns, via a trigger, or by another application.

(7)

property-ref: (optional) The name of the key property of the associated class. This property will be used to bind. If not specified, the primary key of the associated class is used.

(8)

access (optional - defaults to property): The strategy that Hibernate uses to access the value of a given field.

The cascade attribute can take the following values: all, save-update, delete, none. Setting a value other than none will entail certain operations on the associated (child) object. See "Object Life Cycle" below.

The outer-join attribute can take the following three values:

    auto (default) retrieves associated objects using outer join if the associated class does not have a proxy.

    true Always retrieve associated objects using outer join.

    false Never retrieve associated objects using outer join.

A typical many-to-one association declaration looks like this

The property-ref attribute is used only for linking with inherited data when the foreign key refers to a unique value of the associated table other than the primary key. This is a dangerous relational decision. For example, it is possible that the Product class has a unique sequence number that is not the primary key. (The unique attribute controls Hibernate's DDL generation. Generation is done using the SchemaExport utility.)

The mapping for OrderItem can use:

In fact, doing this is highly discouraged.

5.1.11. one-to-one

A one-to-one association with another persistent class can be declared using the one-to-one element.

(1)

name: Property name.

(2)

class (optional - by default determined by reflection based on the field type): The name of the associated class.

(3)

cascade (optional) specifies which operation will be cascaded from the parent object to the associated object.

(4)

constrained (optional) specifies that a foreign key referencing a table of the associated class is constrained by that table's primary key. This option affects the order in which the save() and delete() cascade operations are performed (and is also used by the schema export tool).

(5)

outer-join (optional - defaults to auto): Enables retrieval of associated objects using outer-joins if the hibernate.use_outer_join configuration file option is enabled.

(6)

property-ref: (optional) The name of the property of the associated class that is included in the primary key of this class.

(7)

If not specified, the primary key of the associated class is used.

access (optional, defaults to property): The strategy that Hibernate should use to access this field.

    There are two types of one-to-one associations:

    primary key relationship

relationship using a unique foreign key

To organize an association using a primary key, there is no need for additional columns; If two records are related by such an association, it means that two records in two tables have the same primary key value. Therefore, if you want to associate two objects so that they are related by a primary key, then you must make sure that their IDs are set to the same value!

Now we need to make sure that the primary keys of the related records in the tables are identical. We use a special Hibernate foreign generator:

employee ...

The persisted instance of the Person class is assigned the same primary key value that is assigned to the instance of the Employee class referenced by the employee property of the Person class.

As an alternative to describing the one-to-one relationship from Employee to Person through a unique foreign key, you can use the following notation:

This association can be made bidirectional by adding the following expression to the mapping of the Person class:

5.1.12. component, dynamic-component

Element maps the fields of a nested object to the table columns of the parent class. Components can in turn define their own properties, components, or collections. See "Components" below.

(5) ........

(1)

name: The name of the property (referring to the component object).

(2)

class (optional - by default the component type is determined using reflection): The name of the component class.

(3)

insert: If set to true, the component's displayed fields participate in SQL INSERT queries.

(4)

update: If set to true, the component's displayed fields participate in SQL UPDATE queries.

(5)

access (optional - defaults to property): The strategy that Hibernate should use when accessing this bean through its parent object.

Nested tags Map component fields into table columns.

Element allows nested element Which renders the component property as a back reference to the parent object.

Element allows you to use a Map as a component in which the field names correspond to the Map's keys.

5.1.13. subclass

Finally, polymorphic persistence requires every subclass of the base class to be declared. For the (recommended) display strategy, table-per-class-hierarchy uses the element .

.....

Each subclass must declare its own persistent fields and subclasses. Inheritance of properties is allowed And from the base class. Each subclass in the hierarchy must define a unique discriminator-value. If this value is not specified, the full class name is used as the discriminator.

5.1.14. joined-subclass

Alternatively, a subclass whose objects are stored in a separate table (table-per-subclass mapping strategy) is declared using the element .

.....

This display strategy does not require the discriminator column to be specified. However, each subclass must declare a table column that contains the identifier to be displayed by the element . The mapping given at the beginning of the section can be rewritten as follows:

The persistent state consists of references to other entities and instances of value types. Values ​​are primitives, collections, components, and other immutable objects. Unlike entities, value type instances (particularly collections and components) are persisted and deleted when available. Because value type objects (and primitives) are stored and deleted along with their containing entity, they cannot have independent versioning. Values ​​also do not have an independent identity and thus cannot be shared between two entities or collections.

All types in Hibernate, with the exception of collections, support null pointer semantics.

Up to this point, we have used the term "persistent class" to refer to entities. We will continue to do this. Strictly speaking, not all user-defined classes with persistent state are entities. For example, a component is a user-defined class with value-type semantics (components are part of the entities that contain them, and are considered fields of those entities).

5.2.2. Basic value types

The basic types can be roughly divided as follows

integer, long, short, float, double, character, byte, boolean, yes_no, true_false

Mappings of primitive Java types or wrapper classes to the corresponding (vendor-dependent) SQL types of table columns. boolean, yes_no, and true_false are alternative notations for the Java types boolean or java.lang.Boolean.

string

Mapping java.lang.String type to VARCHAR (or Oracle VARCHAR2).

date, time, timestamp

Mapping the java.util.Date type and its subclasses to the SQL types DATE, TIME, and TIMESTAMP (or equivalent).

calendar, calendar_date

Mapping the java.util.Calendar type to the SQL types TIMESTAMP and DATE (or equivalent).

big_decimal

Mapping type java.math.BigDecimal to NUMERIC (or Oracle NUMBER).

locale, timezone, currency

Mapping java.util.Locale, java.util.TimeZone, and java.util.Currency types to VARCHAR (or Oracle VARCHAR2). Locale and Currency instances are mapped to their ISO codes. TimeZone instances are mapped to their identifiers (IDs).

class

Mapping type java.lang.Class to VARCHAR (or Oracle VARCHAR2). Class is displayed as its full name.

binary

Maps byte arrays to the corresponding binary SQL type.

text

Displays long Java strings in SQL CLOB or TEXT.

serializable

Maps serializable Java types to corresponding binary SQL types. You can also denote the Hibernate serializable type as the name of a serializable Java class or interface that is not a base type and does not implement the PersistentEnum interface.

clob, blob

JDBC type mapping of the java.sql.Clob and java.sql.Blob classes. These types may be inconvenient for some applications because blob and clob objects cannot be used outside of transactions. (In addition, drivers do not fully and uniformly support these types.)

Unique identifiers for entities and collections can be of any basic type except binary, blob, and clob. (Composite identifiers are also allowed, see below.)

Basic value types are described by constants declared in net.sf.hibernate.Hibernate. For example, Hibernate.STRING represents the string type.

5.2.3. Persistent enum types

An enumerated type is a basic Java idiom when a class has a constant (small) number of immutable instances (translator's note in Java 5 this was introduced at the language level, in earlier versions a special pattern was used for this). You can create persistent enum types by implementing the net.sf.hibernate.PersistentEnum interface, and defining the toInt() and fromInt() operations:

Package eg; import net.sf.hibernate.PersistentEnum; public class Color implements PersistentEnum ( private final int code; private Color(int code) ( this.code = code; ) public static final Color TABBY = new Color(0); public static final Color GINGER = new Color(1); public static final Color BLACK = new Color(2); public int toInt() ( return code; ) public static Color fromInt(int code) ( switch (code) ( case 0: return TABBY; case 1: return GINGER; case 2: return BLACK; default: throw new RuntimeException("Unknown color code");

The name of a Hibernate type is simply the name of the enumerated class, in this case eg.Color.

5.2.4. Custom value types

It is relatively easy for developers to create their own value types. For example, you might want to store properties of type java.lang.BigInteger into columns of type VARCHAR. Hibernate doesn't provide a built-in type for this. But defining custom types is not limited to mapping properties (or collection elements) to a single table column. So, for example, you can have a property getName()/setName() of type java.lang.String which is stored in the FIRST_NAME, INITIAL, SURNAME columns.

To implement a custom type, implement one of the net.sf.hibernate.UserType or net.sf.hibernate.CompositeUserType interfaces and declare the property using the fully qualified class name of your type implementation. Review net.sf.hibernate.test.DoubleStringType for available capabilities.

Note: use tags to display properties in multiple columns.

Although Hibernate's wealth of built-in types and component support means that you rarely need to use custom types, it is still good practice to use them as (non-entity) classes for types that are frequently used in your application. For example, the MonetoryAmount class is a good candidate for CompositeUserType, although it can be exposed as a component. The main motivation is abstraction. With custom types, your mapping document will be more resilient to possible changes in the future if you change the currency type representation.

5.2.5. Any type display

There is another type for displaying properties. Display element declares a polymorphic association for classes from multiple tables. This type of display always requires more than one column. The first column contains the type of the associated entity. The remaining columns contain the identifier. It is not possible to define a foreign key for a given association type, so this mapping is not typically used for polymorphic associations. You should use this mapping only in special cases (for example, recording different types of data, accessing user session data).

The meta-type attribute allows an application to define a custom type that maps database column values ​​to persistent classes whose identifier properties are of the type defined by id-type. If the meta-type returns java.lang.Class entities, then nothing else is required. In other cases, when it is a base type such as string or character, you must map the values ​​to the classes.

..... .....

(1)

name: Property name.

(2)

id-type: Identifier type.

(3)

meta-type (optional - defaults to class): a type that maps java.lang.Class into a single database column, or alternatively a type that is allowed to map a discriminator.

(4)

cascade (optional - defaults to none): The type of cascade operation.

(5)

access (optional - defaults to property): The strategy that Hibernate should use to access the value of a property.

The old object property, which has its own place in Hibernate 1.2, is still supported but has been deprecated.

5.3. SQL identifiers in quotes

You can force Hibernate to quote identifiers in SQL statements. Hibernate will follow the quoting rules according to the specified SQL dialect (usually double quotes, but parentheses for SQL Server and backquotes for MySQL).

...

5.4. Individual display files

You can declare subclass and joined-subclass mappings in separate documents, right inside the hibernate-mapping element. This allows the class hierarchy to be expanded by adding a new mapping file. With this approach, you must specify an extends attribute in the subclass mapping containing the name of the pre-mapped superclass. Using this feature makes the order in which the mapping documents are listed important.