-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Identifier generator for UserType
PostPosted: Thu Jan 12, 2006 12:41 am 
Newbie

Joined: Sun Jan 01, 2006 12:53 pm
Posts: 11
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:


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.