本文整理汇总了C#中ISessionFactoryImplementor.GetImplementors方法的典型用法代码示例。如果您正苦于以下问题:C# ISessionFactoryImplementor.GetImplementors方法的具体用法?C# ISessionFactoryImplementor.GetImplementors怎么用?C# ISessionFactoryImplementor.GetImplementors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISessionFactoryImplementor
的用法示例。
在下文中一共展示了ISessionFactoryImplementor.GetImplementors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetEntityPersister
protected virtual IEntityPersister GetEntityPersister(ISessionFactoryImplementor factory, string entityName)
{
// Check for an exact match.
IEntityPersister persister = factory.TryGetEntityPersister(entityName);
if (persister != null)
{
return persister;
}
// Couldn't find persister through exact name, try finding a single implementing class.
string[] implementors = factory.GetImplementors(entityName);
if (implementors.Length > 1)
{
var messageBuilder = new StringBuilder(512);
messageBuilder.AppendLine(string.Format("Ambiguous persister for {0} implemented by more than one hierarchy: ",
entityName));
Array.ForEach(implementors, s=> messageBuilder.AppendLine(s));
throw new HibernateException(messageBuilder.ToString());
}
if (implementors.Length == 0)
{
return null;
}
return factory.GetEntityPersister(implementors[0]);
}
示例2: ConcreteQueries
public string[] ConcreteQueries(string query, ISessionFactoryImplementor factory)
{
// TODO H3.2 check if the QuerySplitter can do the work (this method is not present in H3.2)
//scan the query string for class names appearing in the from clause and replace
//with all persistent implementors of the class/interface, returning multiple
//query strings (make sure we don't pick up a class in the select clause!)
//TODO: this is one of the ugliest and most fragile pieces of code in Hibernate...
string[] tokens = StringHelper.Split(ParserHelper.Whitespace + "(),", query, true);
if (tokens.Length == 0)
{
return new String[] {query};
} // just especially for the trivial collection filter
var placeholders = new List<object>();
var replacements = new List<object>();
StringBuilder templateQuery = new StringBuilder(40);
int count = 0;
string last = null;
int nextIndex = 0;
string next = null;
templateQuery.Append(tokens[0]);
for (int i = 1; i < tokens.Length; i++)
{
//update last non-whitespace token, if necessary
if (!ParserHelper.IsWhitespace(tokens[i - 1]))
{
last = tokens[i - 1].ToLowerInvariant();
}
string token = tokens[i];
if (!ParserHelper.IsWhitespace(token) || last == null)
{
// scan for the next non-whitespace token
if (nextIndex <= i)
{
for (nextIndex = i + 1; nextIndex < tokens.Length; nextIndex++)
{
next = tokens[nextIndex].ToLowerInvariant();
if (!ParserHelper.IsWhitespace(next))
{
break;
}
}
}
//if ( Character.isUpperCase( token.charAt( token.lastIndexOf(".") + 1 ) ) ) {
// added the checks for last!=null and next==null because an ISet can not contain
// a null key in .net - it is valid for a null key to be in a java.util.Set
if (
((last != null && beforeClassTokens.Contains(last)) && (next == null || !notAfterClassTokens.Contains(next))) ||
PathExpressionParser.EntityClass.Equals(last))
{
System.Type clazz = Helper.GetImportedClass(token);
if (clazz != null)
{
string[] implementors = factory.GetImplementors(clazz.FullName);
string placeholder = "$clazz" + count++ + "$";
if (implementors != null)
{
placeholders.Add(placeholder);
replacements.Add(implementors);
}
token = placeholder; //Note this!!
}
}
}
templateQuery.Append(token);
}
string[] results =
StringHelper.Multiply(templateQuery.ToString(), placeholders.GetEnumerator(), replacements.GetEnumerator());
if (results.Length == 0)
{
log.Warn("no persistent classes found for query class: " + query);
}
return results;
}
示例3: ConcreteQueries
/// <summary>
/// Handle Hibernate "implicit" polymorphism, by translating the query string into
/// several "concrete" queries against mapped classes.
/// </summary>
/// <param name="query"></param>
/// <param name="factory"></param>
/// <returns></returns>
/// <exception cref="NHibernate.MappingException"/>
public static string[] ConcreteQueries(string query, ISessionFactoryImplementor factory)
{
//scan the query string for class names appearing in the from clause and replace
//with all persistent implementors of the class/interface, returning multiple
//query strings (make sure we don't pick up a class in the select clause!)
//TODO: this is one of the ugliest and most fragile pieces of code in Hibernate....
SessionFactoryHelper helper = new SessionFactoryHelper(factory);
string[] tokens = StringHelper.Split(StringHelper.WhiteSpace + "(),", query, true);
if (tokens.Length == 0)
{
return new String[] {query}; // just especially for the trivial collection filter
}
ArrayList placeholders = new ArrayList();
ArrayList replacements = new ArrayList();
StringBuilder templateQuery = new StringBuilder(40);
int count = 0;
string last = null;
int nextIndex = 0;
string next = null;
templateQuery.Append(tokens[0]);
bool isSelectClause = StringHelper.EqualsCaseInsensitive("select", tokens[0]);
for (int i = 1; i < tokens.Length; i++)
{
//update last non-whitespace token, if necessary
if (!ParserHelper.IsWhitespace(tokens[i - 1]))
{
last = tokens[i - 1].ToLowerInvariant();
}
// select-range is terminated by declaration of "from"
isSelectClause = !StringHelper.EqualsCaseInsensitive("from", tokens[i]);
string token = tokens[i];
if (!ParserHelper.IsWhitespace(token) || last == null)
{
//scan for next non-whitespace token
if (nextIndex <= i)
{
for (nextIndex = i + 1; nextIndex < tokens.Length; nextIndex++)
{
next = tokens[nextIndex].ToLowerInvariant();
if (!ParserHelper.IsWhitespace(next))
{
break;
}
}
}
// TODO H3.2 Different behavior
// NHb: This block is not an exactly port from H3.2 but a port from previous implementation of QueryTranslator
if (((last != null && beforeClassTokens.Contains(last)) &&
(next == null || !notAfterClassTokens.Contains(next))) ||
PathExpressionParser.EntityClass.Equals(last))
{
System.Type clazz = helper.GetImportedClass(token);
if (clazz != null)
{
string[] implementors = factory.GetImplementors(clazz.FullName);
string placeholder = "$clazz" + count++ + "$";
if (implementors != null)
{
placeholders.Add(placeholder);
replacements.Add(implementors);
}
token = placeholder; //Note this!!
}
}
}
templateQuery.Append(token);
}
string[] results =
StringHelper.Multiply(templateQuery.ToString(), placeholders.GetEnumerator(), replacements.GetEnumerator());
if (results.Length == 0)
{
log.Warn("no persistent classes found for query class: " + query);
}
return results;
}