HBM Hibernate many-to-many bidirectional connection with extra column - mysql

i googled a lot and did follow many tutorials about it, but i didnt get it to work. I have a many-to-many relation between the table Player and Type. Both tables are connected via typeperplayer. In the table typeperplayer is an additional column paid, which i want to use in hibernate.
Here is the database scheme:
Player:
Play_ID : int
Play_FirstName : string
Play_LastName : string
Typeperplayer:
Typl_ID : int
Typl_Play_ID : int
Typl_Type_ID : int
Typl_Paid : int
Type
Type_ID : int
Type_Name : string
Here is my Hibernate-Mapping:
Player:
<hibernate-mapping>
<class name="de.tt.treg.server.domain.Player" table="player">
<id name="id" type="java.lang.Integer">
<column name="Play_ID" />
<generator class="identity" />
</id>
<property name="firstName" type="string">
<column name="Play_FirstName" length="255" not-null="false" unique="false" />
</property>
<property name="lastName" type="string">
<column name="Play_LastName" length="255" not-null="false" unique="false" />
</property>
<set name="competitions" table="typeperplayer"
inverse="true" lazy="false" fetch="select">
<key>
<column name="typl_play_id" not-null="true" />
</key>
<one-to-many class="de.tt.treg.server.domain.PlayerCompetition" />
</set>
</class>
PlayerCompetition (Typeperplayer)
<hibernate-mapping package="de.tt.treg.server.domain">
<class name="PlayerCompetition" table="typeperplayer">
<composite-id name="playerCompetitionPk"
class="PlayerCompetitionPk">
<key-property name="id" column="Typl_Play_Id"
type="java.lang.Integer" />
<key-property name="id" column="Typl_Type_Id"
type="java.lang.Integer" />
</composite-id>
<property name="paid" type="java.lang.Integer">
<column name="Typl_Paid" length="10" not-null="false" unique="false" />
</property>
<many-to-one name="player" class="Player" insert="false" update="false"/>
<many-to-one name="competition" class="Competition" insert="false" update="false"/>
</class>
Competition (Type):
<hibernate-mapping>
<class name="de.tt.treg.server.domain.Competition" table="type">
<id name="id" type="java.lang.Integer">
<column name="Type_ID" />
<generator class="identity" />
</id>
<property name="name" type="string">
<column name="Type_Name" length="255" not-null="false" unique="false" />
</property>
<set name="players" table="typeperplayer"
inverse="false" lazy="true" fetch="select">
<key>
<column name="Type_Id" not-null="true" />
</key>
<one-to-many class="de.tt.treg.server.domain.PlayerCompetition" />
</set>
</class>
Additionally here are my classes:
public class Player{
private int id;
private String firstName;
private String lastName;
private Set<PlayerCompetition> competitions = new HashSet<PlayerCompetition>();
public Player() {
}
public Player(String firstName, String lastName,
Set<PlayerCompetition> competitions) {
this.firstName = firstName;
this.lastName = lastName;
this.competitions = competitions;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public Set<PlayerCompetition> getCompetitions() {
return competitions;
}
public void setCompetitions(Set<PlayerCompetition> competitions) {
this.competitions = competitions;
}
}
public class PlayerCompetition {
private int id;
private int paid;
private PlayerCompetitionPk playerCompetitionPk;
public PlayerCompetition() {
}
public PlayerCompetition(int id, int paid,
PlayerCompetitionPk competitionPk) {
super();
this.id = id;
this.paid = paid;
this.playerCompetitionPk = competitionPk;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getPaid() {
return paid;
}
public void setPaid(int paid) {
this.paid = paid;
}
public PlayerCompetitionPk getPlayerCompetitionPk() {
return playerCompetitionPk;
}
public void setPlayerCompetitionPk(PlayerCompetitionPk playerCompetitionPk) {
this.playerCompetitionPk = playerCompetitionPk;
}
public Player getPlayer() {
return getPlayerCompetitionPk().getPlayer();
}
public void setPlayer(Player player) {
getPlayerCompetitionPk().setPlayer(player);
}
public Competition getCompetition() {
return getPlayerCompetitionPk().getCompetition();
}
public void setCompetition(Competition competition) {
getPlayerCompetitionPk().setCompetition(competition);
}
}
public class PlayerCompetitionPk {
private int id;
private Player player;
private Competition competition;
public PlayerCompetitionPk() {
}
public int getId() {
return id;
}
public Player getPlayer() {
return player;
}
public void setPlayer(Player player) {
this.player = player;
}
public Competition getCompetition() {
return competition;
}
public void setCompetition(Competition competition) {
this.competition = competition;
}
public void setId(int id) {
this.id = id;
}
}
public class Competition {
private int id;
private String name;
private Set<PlayerCompetition> players;
public Competition() {
}
public Competition(int id, String name) {
this.id = id;
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set<PlayerCompetition> getPlayers() {
return players;
}
public void setPlayers(Set<PlayerCompetition> players) {
this.players = players;
}
}
I hope somebody can help me. If you need some additional information, you will get it ;-). Thank you.
Here is the generated sql statement:
select player0_.Play_ID as Play1_1_2_, player0_.Play_Club_ID as Play2_1_2_, player0_.Play_User_ID as Play3_1_2_, player0_.Play_FirstName as Play4_1_2_, player0_.Play_LastName as Play5_1_2_, player0_.Play_BirthDate as Play6_1_2_, team1_.Club_ID as Club1_0_0_, team1_.Club_Name as Club2_0_0_, team1_.Club_ShortName as Club3_0_0_, team1_.Club_Verband as Club4_0_0_, user2_.User_ID as User1_4_1_, user2_.User_Name as User2_4_1_, user2_.User_Passwort as User3_4_1_, user2_.User_RegisterDate as User4_4_1_ from player player0_ inner join club team1_ on player0_.Play_Club_ID=team1_.Club_ID inner join user user2_ on player0_.Play_User_ID=user2_.User_ID where player0_.Play_ID=?
In this statement are two joins with the other tables club and users. But there is no join with via typeperplayer.

The solution is to not directly map the player and type entities with a many-to-many relation, but instead have an intermediate entity playertype which you connect with one-to-many to both player and type.
That way you can use additional columns as properties on the playertype entity.
player <1-*> playertype <*-1> type
Edit:
Here's a nice example from mkyong
http://www.mkyong.com/hibernate/hibernate-many-to-many-example-join-table-extra-column-annotation/

Related

java EE Hibernate List many to many configure error

I am making a java ee web application. I have User and Permission classes and User class have List that types of Permission. When hibernate gets user object form database, i want to get permissions of user from user_permission table ,too. User and Permission has many-to-many relation. I am using Hibernate 5.4.1 . When SessionFactory configurating i get this error:
java.lang.NullPointerException
org.hibernate.boot.model.source.internal.hbm.ModelBinder$AbstractPluralAttributeSecondPass.bindCollectionElement(ModelBinder.java:3557)
org.hibernate.boot.model.source.internal.hbm.ModelBinder$AbstractPluralAttributeSecondPass.doSecondPass(ModelBinder.java:3136)
org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1684)
org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1652)
org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:286)
org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83)
org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:473)
org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:84)
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:689)
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
my User class:
public class User
{
private int id;
private String name;
private String password;
private List<Permission> permissions;
public User(){}
public User(String name,String password)
{
this.name=name;
this.password=password;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name=name;
}
public String getPassword()
{
return password;
}
public void setPassword(String password)
{
this.password=password;
}
public int getId()
{
return id;
}
public void setId(int id)
{
this.id=id;
}
public void clearPermissions()
{
permissions.clear();
}
public boolean hasPermission(Permission permission)
{
return permissions.contains(permission);
}
public void addPermission(Permission permission)
{
permissions.add(permission);
}
public void deletePermission(Permission permission)
{
permissions.remove(permission);
}
public List<Permission> getPermissions()
{
return permissions;
}
public void setPermissions(List<Permission> permissions)
{
this.permissions = permissions;
}
}
user class mapping :
<?xml version="1.0" encoding="UTF-8"?>
<hibernate-mapping>
<class name="model.User" table="user">
<id name="id" type="int" column="id">
<generator class="identity"/>
</id>
<property name="name" column="name" type="string"/>
<property name="password" column="password" type="string"/>
<list name="permissions" table="user_permission" lazy="false">
<key column="user_id"/>
<index column="id"/>
<many-to-many class="Permission" column="permission_id"/>
</list>
</class>
</hibernate-mapping>
my Permission class:
public class Permission
{
private int id;
private String name;
public Permission() {}
public Permission(int id, String name)
{
this.id=id;
this.name=name;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name=name;
}
public int getId()
{
return id;
}
public void setId(int id)
{
this.id=id;
}
public boolean equals(Object obj)
{
return ((Permission)obj).id==id;
}
}
Permission class mapping :
<?xml version="1.0" encoding="UTF-8"?>
<hibernate-mapping>
<class name="model.Permission" table="permission">
<id name="id" type="int" column="id">
<generator class="identity"/>
</id>
<property name="name" column="name" type="string"/>
</class>
</hibernate-mapping>
There is a missing packageName in many to many mapping. Change it from Permission to model.Permission. It should solve the problem. Below is the sippet
<class name="model.User" table="user">
<id name="id" type="int" column="id">
<generator class="identity"/>
</id>
<property name="name" column="name" type="string"/>
<property name="password" column="password" type="string"/>
<list name="permissions" table="user_permission" lazy="false">
<key column="user_id"/>
<index column="id"/>
<many-to-many class="model.Permission" column="permission_id"/>
</list>
</class> </hibernate-mapping>

Spring MVC with jdbc "table is not mapped"

So I´m trying to make an application with all http request get, put, post, delete.I'm making first a login with mysql and spring 3. So here I got this:
login.jsp:
<form:form id="myForm" method="post"
class="bs-example form-horizontal" commandName="UsersLogin">
signup.jsp
<form:form id="myForm" method="post"
class="bs-example form-horizontal" commandName="Users">
persistence.xml:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="{http://java.sun.com/xml/ns/persistence} {http://java.sun.com/xml/ns/persistence_2_0.xsd}"
version="2.0">
<persistence-unit name="punit">
</persistence-unit>
</persistence>
Here is my jpaContext.xml:
<context:annotation-config />
<jpa:repositories base-package="com.portuzona.repository" />
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="punit" />
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true" />
</bean>
</property>
<property name="jpaPropertyMap">
<map>
<entry key="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<entry key="hibernate.hbm2ddl.auto" value="validate" />
<entry key="hibernate.format_sql" value="true" />
</map>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/portuzona?autoReconnect=true&createDatabaseIfNotExist=true&" />
<property name="username" value="root" />
<property name="password" value="1234" />
</bean>
</beans>
com.portuzona.model
Users model:
#Entity
#Table(name="users")
public class Users {
#Id
#GeneratedValue
private Long id;
#NotEmpty
#Size(min=4, max=20)
private String userName;
#NotEmpty
private String firstName;
#NotEmpty
private String lastName;
#NotEmpty
#Size(min=4, max=8)
private String password;
#NotEmpty
private String status;
#NotEmpty
#Email
private String emailAddress;
#NotNull
#Past
#DateTimeFormat(pattern="MM/dd/yyyy")
private Date dateOfBirth;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getEmailAddress() {
return emailAddress;
}
public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}
public Date getDateOfBirth() {
return dateOfBirth;
}
public void setDateOfBirth(Date dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}
}
USersLogin model:
public class UsersLogin {
#NotEmpty
#Size(min=4, max=20)
private String userName;
#NotEmpty
#Size(min=4, max=8)
private String password;
public String getPassword() {
return password;
}
public String getUserName() {
return userName;
}
public void setPassword(String password) {
this.password = password;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
com.portuzona.service
public interface UsersService {
Users save(Users users);
boolean findByLogin(String userName, String password);
boolean findByUserName(String userName);
}
Implementation:
#Service("UsersService")
public class UsersServiceImpl implements UsersService {
#Autowired
private UsersRepository usersRepository;
#Transactional
public Users save(Users users) {
return usersRepository.save(users);
}
public boolean findByLogin(String userName, String password) {
Users stud = usersRepository.findByUserName(userName);
if(stud != null && stud.getPassword().equals(password)) {
return true;
}
return false;
}
public boolean findByUserName(String userName) {
Users use = usersRepository.findByUserName(userName);
if(use != null) {
return true;
}
return false;
}
}
com.portuzona.repository
#Repository("UsersRepository")
public interface UsersRepository extends JpaRepository<Users, Long> {
#Query("SELECT s FROM users s WHERE s.userName = :userName")
Users findByUserName(#Param("userName") String userName);
}
com.portuzona.controller
#Controller
#SessionAttributes("users")
public class UsersController {
#Autowired
private UsersService userService;
#RequestMapping(value="/signup", method=RequestMethod.GET)
public String signup(Model model) {
Users users = new Users();
model.addAttribute("users", users);
return "signup";
}
#RequestMapping(value="/signup", method=RequestMethod.POST)
public String signup(#Valid #ModelAttribute("users") Users users, BindingResult result, Model model) {
if(result.hasErrors()) {
return "signup";
} else if(userService.findByUserName(users.getUserName())) {
model.addAttribute("message", "User Name exists. Try another user name");
return "signup";
} else {
userService.save(users);
model.addAttribute("message", "Saved users details");
return "redirect:login.html";
}
}
#RequestMapping(value="/login", method=RequestMethod.GET)
public String login(Model model) {
UsersLogin usersLogin = new UsersLogin();
model.addAttribute("UsersLogin", usersLogin);
return "login";
}
#RequestMapping(value="/login", method=RequestMethod.POST)
public String login(#Valid #ModelAttribute("UsersLogin") UsersLogin usersLogin, BindingResult result) {
if (result.hasErrors()) {
return "login";
} else {
boolean found = userService.findByLogin(usersLogin.getUserName(), usersLogin.getPassword());
if (found) {
return "success";
} else {
return "failure";
}
}
}
}
I got this error when trying to access to /login or /signup where I have my .jsp with my forms:
sep 24, 2015 11:14:35 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet usersHibernateServlet
org.hibernate.hql.internal.ast.QuerySyntaxException: users is not mapped [SELECT s FROM users s WHERE s.userName = :userName]
I have been with this for two days, looking for answers here but no kind of good results from my side... just gives me the same error, any idea?

When I am changing the size of the entity field it is not getting changed in database

I have a entity class group.
before change
#Entity
#Table(name = "Group")
public class Group implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
private String name;
#Deprecated
public Group() {
// Do not Use. Required by JPA Spec
}
public Group(Long id) {
this.id = id;
}
#Id
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
#NotNull
#Size(min = 2, max = 75)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
#Override
public boolean equals(Object o) {
if (o instanceof User) {
return getId().equals(((Group) o).getId());
}
else {
return false;
}
}
Now I changed the max size of the name from 75 to 1000.
#Entity
#Table(name = "Group")
public class Group implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
private String name;
#Deprecated
public Group() {
// Do not Use. Required by JPA Spec
}
public Group(Long id) {
this.id = id;
}
#Id
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
#NotNull
#Size(min = 2, max = 1000)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
#Override
public boolean equals(Object o) {
if (o instanceof User) {
return getId().equals(((Group) o).getId());
}
else {
return false;
}
}
After this change the length of the name in the database is not getting changd from 75 to 1000.
The persistance.xml looks like
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="primary" transaction-type="JTA">
<jta-data-source>java:jboss/datasources/sampleDS</jta-data-source>
<properties>
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
</properties>
</persistence-unit>
</persistence>
Hibernate's schema update feature (hibernate.hbm2ddl.auto=update) is very limited and cannot be relied on. It will add new tables, fields and foreign keys, but that's about all it does.
If your schema changes, you'll need some kind of migration mechanism, such as Liquibase. Relying on Hbm2ddl in production is a recipe for disaster.

Unique value for person last name and first name class in hibernate

Hi I want to have a unique last name and first name for my person table in my database .
my hibernate xml map for person is
package com.me.POJO;
public class Person {
private int personId;
private String firstName;
private String lastName;
private String streetAddress;
private String aptNo;
private String city;
private int zipCode;
public Person(){}
public Person(String firstName, String lastName, String streetAddress,
String aptNo, String city, int zipCode) {
this.firstName = firstName;
this.lastName = lastName;
this.streetAddress = streetAddress;
this.aptNo = aptNo;
this.city = city;
this.zipCode = zipCode;
}
public int getPersonId() {
return personId;
}
public void setPersonId(int personId) {
this.personId = personId;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getStreetAddress() {
return streetAddress;
}
public void setStreetAddress(String streetAddress) {
this.streetAddress = streetAddress;
}
public String getAptNo() {
return aptNo;
}
public void setAptNo(String aptNo) {
this.aptNo = aptNo;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public int getZipCode() {
return zipCode;
}
public void setZipCode(int zipCode) {
this.zipCode = zipCode;
}
}
my Hibernate hbm.xml file for person is :
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Apr 9, 2012 2:49:54 PM by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
<class name="com.me.POJO.Person" table="Person">
<id name="personId" type="int">
<column name="personId_PK" />
<generator class="native"></generator>
</id>
<property name="aptNo" type="java.lang.String">
<column name="aptNo" />
</property>
<property name="city" type="java.lang.String">
<column name="city" />
</property>
<property name="firstName" type="java.lang.String">
<column name="firstName" />
</property>
<property name="lastName" type="java.lang.String">
<column name="lastName" />
</property>
<property name="streetAddress" type="java.lang.String">
<column name="streetAddress" />
</property>
<property name="zipCode" type="int">
<column name="zipCode" not-null="true" />
</property>
</class>
</hibernate-mapping>
is there any way i can add unique constraint in the person mapping in the hbm file so that my first name and last name are unique in the database/
Thanks a lot in advance.
You can make a natural key that containing last name and first name using the <natural-id> element.
Please note that <natural-id> only help to create an unique constraint on the natural key columns when the table schema is generated by Hibernate hbm2ddl . Hibernate will not do any uniqueness validation on <natural-id> columns at the run-times.
So , if you don't plan to re-create the table schema using Hibernate , you can simply manually adding the unique constraint for these columns using DDL and let the database check the uniqueness.

Nhibernate Guid with PK MySQL

I've got a question. I use NHibernate with MySql. At my entities I use Id(PK) for my business-logic usage and Guid(for replication). So my BaseDomain:
public class BaseDomain
{
public virtual int Id { get; set; }
public virtual Guid Guid { get; set; }
public class Properties
{
public const string Id = "Id";
public const string Guid = "Guid";
}
public BaseDomain() { }
}
My usage domain:
public class ActivityCategory : BaseDomain
{
public ActivityCategory() { }
public virtual string Name { get; set; }
public new class Properties
{
public const string Id = "Id";
public const string Guid = "Guid";
public const string Name = "Name";
private Properties() { }
}
}
Mapping:
<class name="ActivityCategory, Clients.Core" table='Activity_category'>
<id name="Id" unsaved-value="0" type="int">
<column name="Id" not-null="true"/>
<generator class="native"/>
</id>
<property name="Guid"/>
<property name="Name"/>
</class>
But when I insert my entity:
[Test]
public void Test()
{
ActivityCategory ac = new ActivityCategory();
ac.Name = "Test";
using (var repo = new Repository<ActivityCategory>())
repo.Save(ac);
}
I always get '00000000-0000-0000-0000-000000000000' at my Guid field.
What should I do for generate right Guid. May be mapping?
Thanks a lot!
From a NHibernate perspective, you should either set the guid in C# or tell NHibernate that it is generated by the database.
In the former case, set the guid property in the constructor.
public class BaseDomain
{
public BaseDomain()
{
Guid = Guid.NewGuid();
}
}
You map a property whose value is generated in the database like this. Depending on how the value is generated, you may also need to exclude the property from insert statements.
<class name="ActivityCategory, Clients.Core" table="Activity_category">
<id name="Id" not-null="true" >
<generator class="native" />
</id>
<property name="Guid" generated="insert" insert="false" update="false" />
<property name="Name" />
</class>