db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Warrick <philip.warr...@mcgill.ca>
Subject Re: OJB Alias / UserAlias
Date Thu, 23 Sep 2004 04:25:30 GMT
Hi Jakob,

> you are the alias specialist, so i'm contacting you directly.
> i would like to clean up alias handling and was thinking about holding 
> UserAlias only to get rid of m_alias and m_aliasPath instvars. whenever 
> i use setAlias(String) or setAlias(String,String) i'd like to create a 
> UserAlias. this is imo no problem in SelectionCriteria, because we have 
> the attribute there. But what do i do in Criteria ? create a UserAlias 
> with name only ? Criteria#getUserAlias(Object attribute) picks the 
> UserAlias if available so it would get the 'empty' UserAlias instead of 
> building a new one.
> another question is whether we really need a UserAlias on 
> SelectionCriteria level. isn't it sufficient to have on UserAlias on 
> Criteria level and simply add the SelectionCriteria attributes ?

It's true that it is redundant to have instvars of m_alias and 
m_aliasPath at both the Criteria and SelectionCriteria levels.  There 
can only be one UserAlias per Criteria, no matter how many 
SelectionCriteria are associated with it.  So I would agree to put it at 
the Criteria level only.  There are calls to UserAlias methods of 
SelectionCriteria object (e.g. SqlQueryStatement#appendSQLClause(...)) 
so perhaps these methods should remain at the SelectionCriteria level, 
but delegate their work to their Criteria object.

Instead of delegating to SelectionCriteria#setAlias(String alias), 
Criteria#setAlias(String alias) can get the attributes it needs 
directly, something like:

// propagate to SelectionCriteria,not to Criteria
for (int i = 0; i < m_criteria.size(); i++)
	if (!(m_criteria.elementAt(i) instanceof Criteria))
		String attributePath = ((String)((SelectionCriteria) 				 
		boolean allPathsAliased = true;
		m_userAlias = new UserAlias(alias, attributePath, 						allPathsAliased);	

The original assumption behind this method, i.e. that the 
SelectionCriteria have been added to the Criteria before setAlias is 
called, still holds.

Hope this helps,


To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org

View raw message