Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.0
Mapping documents: This is regarding the userType problem
<hibernate-mapping
>
<class
name="ex.Article"
table="t_article"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
optimistic-lock="version"
>
<id name="articleCompId" type="ex.ArticleUserTypeId">
<column name="article_id"/>
<column name="article_version"/>
<!-- <generator class="select"/>
<generator class="ex.ArticleIdentifierGenerator"/> -->
</id>
</class>
</hibernate-mapping>
in the above mapping article_id is autogenerated by db and articleversion is assigned by user. could u plase show some way to write the Generator(ID Generator) or some other way.
In the article(above) table we have two primary key columns one is articleId(that is autogenerated by database -- autoIncremented) and the other (article_version) is assigned. If we save the article with out assigning the articleId to the article entity the database will generate the key for articleId. so here we need that key to be populated into the application level(we have to get it in the article entity) .but it is not comming to the serialised value.
In this we have to write Identifier generator for the composite Id. If u have any idea abt Identifier generator please send me some example on that. That identifier generator should populate the database generated value to the entity.
could u please give some example to write identifier generator to usertype with some explenation..
Code between sessionFactory.openSession() and session.close():
session.save(article);
Full stack trace of any exception that occurs:
Name and version of the database you are using:mysql
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: