-->
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: a bug or not ? this question is from hiberante source code
PostPosted: Thu Sep 27, 2007 7:33 am 
Newbie

Joined: Thu Sep 27, 2007 7:11 am
Posts: 3
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.2
HashMap has been tranformed to TableDescription

(sorry for my bad english)
followed code all from hibernate3.2 src
for readable i changed the order of methods

----------------------------------------------------------------------------
public class Mappings implements Serializable {
Mappings(
.
.
final Map tableNamebinding,
..
){
this.tableNameBinding = tableNamebinding;
}

public void addTableBinding(
String schema, String catalog, String logicalName, String physicalName, Table denormalizedSuperTable
) {
String key = buildTableNameKey( schema, catalog, physicalName );
TableDescription tableDescription = new TableDescription(
logicalName, denormalizedSuperTable
);
//followed code are error code i think
TableDescription oldDescriptor = (TableDescription) tableNameBinding.put( key, tableDescription );//here is my question tableNameBinding is HashMap but TableDescription is a inner class
if ( oldDescriptor != null && ! oldDescriptor.logicalName.equals( logicalName ) ) {
//TODO possibly relax that
throw new MappingException("Same physical table name reference several logical table names: "
+ physicalName + " => " + "'" + oldDescriptor.logicalName + "' and '" + logicalName + "'");//should throw ClassCastException
}
}



static public class TableDescription implements Serializable {
public TableDescription(String logicalName, Table denormalizedSupertable) {
this.logicalName = logicalName;
this.denormalizedSupertable = denormalizedSupertable;
}

public String logicalName;
public Table denormalizedSupertable;
}
}



public class Configuration implements Serializable {

protected Map tableNameBinding;

protected void reset() {
..
tableNameBinding = new HashMap();
..
}


public Mappings createMappings() {
return new Mappings(
....
tableNameBinding,
columnNameBindingPerTable
);
}
public Configuration() {
this( new SettingsFactory() );
}

protected Configuration(SettingsFactory settingsFactory) {
this.settingsFactory = settingsFactory;
reset();
}


public Configuration configure(String resource) throws HibernateException {
..
return doConfigure( stream, resource );// doConfigure(Stream stream, String resource )
}

protected Configuration doConfigure(InputStream stream, String resourceName) throws HibernateException {
..
return doConfigure( doc );//doConfigure(Document doc )
}

protected Configuration doConfigure(org.dom4j.Document doc) throws HibernateException {
..
parseSessionFactory( sfNode, name );//parseSessionFactory( Element sfNode, String name );
..
}

private void parseSessionFactory(Element sfNode, String name) {
..
if ( "mapping".equals( subelementName ) ) {
parseMappingElement( subelement, name );//parseMappingElement(Element subelement, String name);
}
..
}

protected void parseMappingElement(Element subelement, String name) {
..
if ( rsrc != null ) {
log.debug( name + "<-" + rsrc );
addResource( rsrc.getValue() ); // addResource( String rsrc.getValue() );
}
..
}

public Configuration addResource(String resourceName) throws MappingException {
..
try {
return addInputStream( rsrc );//addInputStream( InputStream rsrc )
}
..
}

public Configuration addInputStream(InputStream xmlInputStream) throws MappingException {
..
add( doc );//add(Document)
..
}

protected void add(org.dom4j.Document doc) throws MappingException {
HbmBinder.bindRoot( doc, createMappings(), CollectionHelper.EMPTY_MAP );//
}
}


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.