How do I solve my problem ("WARN: HHH90000028: Support for <hibernate-mappings/> is deprecated [RESOURCE : com/mycompany/hibernatelearningvideos03and04/model/student.hbm.xml]; migrate to orm.xml or mapping.xml, or enable hibernate.transform_hbm_xml.enabled for on the fly transformation")?:
2.4.6. Mapping the entity
The main piece in mapping the entity is the jakarta.persistence.Entity annotation.

The @Entity annotation defines just the name attribute which is used to give a specific entity name for use in JPQL queries.

By default, if the name attribute of the @Entity annotation is missing, the unqualified name of the entity class itself will be used as the entity name.

Because the entity name is given by the unqualified name of the class, Hibernate does not allow registering multiple entities with the same name even if the entity classes reside in different packages.

Without imposing this restriction, Hibernate would not know which entity class is referenced in a JPQL query if the unqualified entity name is associated with more then one entity classes.

In the following example, the entity name (e.g. Book) is given by the unqualified name of the entity class name.

Example 129. @Entity mapping with an implicit name
@Entity
public class Book {

@Id
private Long id;

private String title;

private String author;

//Getters and setters are omitted for brevity
}
However, the entity name can also be set explicitly as illustrated by the following example.

Example 130. @Entity mapping with an explicit name
@Entity(name = “Book”)
public static class Book {

@Id
private Long id;

private String title;

private String author;

//Getters and setters are omitted for brevity
}
An entity models a database table. The identifier uniquely identifies each row in that table. By default, the name of the table is assumed to be the same as the name of the entity. To explicitly give the name of the table or to specify other information about the table, we would use the jakarta.persistence.Table annotation.

Example 131. Simple @Entity with @Table
@Entity(name = “Book”)
@Table(
catalog = “public”,
schema = “store”,
name = “book”
)
public static class Book {

@Id
private Long id;

private String title;

private String author;

//Getters and setters are omitted for brevity
}
Mapping the catalog of the associated table
Without specifying the catalog of the associated database table a given entity is mapped to, Hibernate will use the default catalog associated with the current database connection.

However, if your database hosts multiple catalogs, you can specify the catalog where a given table is located using the catalog attribute of the Jakarta Persistence @Table annotation.

Let’s assume we are using MySQL and want to map a Book entity to the book table located in the public catalog which looks as follows.

Example 132. The book table located in the public catalog
create table public.book (
id bigint not null,
author varchar(255),
title varchar(255),
primary key (id)
) engine=InnoDB
Now, to map the Book entity to the book table in the public catalog we can use the catalog attribute of the @Table Jakarta Persistence annotation.

Example 133. Specifying the database catalog using the @Table annotation
@Entity(name = “Book”)
@Table(
catalog = “public”,
name = “book”
)
public static class Book {

@Id
private Long id;

private String title;

private String author;

//Getters and setters are omitted for brevity
}
Mapping the schema of the associated table
Without specifying the schema of the associated database table a given entity is mapped to, Hibernate will use the default schema associated with the current database connection.

However, if your database supports schemas, you can specify the schema where a given table is located using the schema attribute of the Jakarta Persistence @Table annotation.

Let’s assume we are using PostgreSQL and want to map a Book entity to the book table located in the library schema which looks as follows.

Example 134. The book table located in the library schema
create table library.book (
id int8 not null,
author varchar(255),
title varchar(255),
primary key (id)
)
Now, to map the Book entity to the book table in the library schema we can use the schema attribute of the @Table Jakarta Persistence annotation.

Example 135. Specifying the database schema using the @Table annotation
@Entity(name = “Book”)
@Table(
schema = “library”,
name = “book”
)
public static class Book {

@Id
private Long id;

private String title;

private String author;

//Getters and setters are omitted for brevity
}
The schema attribute of the @Table annotation works only if the underlying database supports schemas (e.g. PostgreSQL).

Therefore, if you’re using MySQL or MariaDB, which do not support schemas natively (schemas being just an alias for catalog), you need to use the catalog attribute, and not the schema one.
To solve the specific error you mentioned, which is related to the deprecation of <hibernate-mappings/>, you need to migrate your mapping configuration from the XML file (e.g., “student.hbm.xml”) to either orm.xml or mapping.xml.

Here are the steps to follow:

1. Create a new XML file (e.g., “student-orm.xml” or “student-mapping.xml”) to replace the deprecated “student.hbm.xml” file.

2. Copy the content of the “student.hbm.xml” file into the new XML file.

3. Open the new XML file and make the necessary changes to update the syntax and element usage according to the updated Hibernate documentation.

4. Update the configuration of your Hibernate SessionFactory to use the new XML file instead of the deprecated “student.hbm.xml”.

5. Build and run your application to ensure that the migration is successful and that the error no longer occurs.

For more detailed information on how to map entities using orm.xml or mapping.xml, you can refer to the Hibernate documentation sections:
- 2.4.6 “Mapping the entity”
- 5.2. Mapping metadata in orm.xml
- 5.3. Mapping metadata in mapping.xml

These sections will provide you with guidance on how to update your XML mapping configuration to resolve the deprecation warning.

The above is from a previous ChatGPT session. Concisely elaborate on the steps.