1
|
|
#region Copyright
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
#endregion
|
18
|
|
|
19
|
|
using System;
|
20
|
|
using System.Reflection;
|
21
|
|
using Seasar.Extension.ADO;
|
22
|
|
using Seasar.Extension.ADO.Impl;
|
23
|
|
using Seasar.Framework.Exceptions;
|
24
|
|
|
25
|
|
namespace Seasar.Dao.Id
|
26
|
|
{
|
27
|
|
public abstract class AbstractIdentifierGenerator : IIdentifierGenerator
|
28
|
|
{
|
29
|
|
private static IDataReaderHandler dataReaderHandler = new ObjectDataReaderHandler();
|
30
|
|
private string propertyName;
|
31
|
|
private IDbms dbms;
|
32
|
|
|
33
|
67
|
public AbstractIdentifierGenerator(string propertyName, IDbms dbms)
|
34
|
|
{
|
35
|
67
|
this.propertyName = propertyName;
|
36
|
67
|
this.dbms = dbms;
|
37
|
|
}
|
38
|
|
|
39
|
0
|
public string PropertyName
|
40
|
|
{
|
41
|
|
get { return this.propertyName; }
|
42
|
|
}
|
43
|
|
|
44
|
|
public IDbms Dbms
|
45
|
|
{
|
46
|
2
|
get { return this.dbms; }
|
47
|
|
}
|
48
|
|
|
49
|
2
|
protected object ExecuteSql(IDataSource ds, string sql, object[] args)
|
50
|
|
{
|
51
|
2
|
BasicSelectHandler handler = new BasicSelectHandler(ds, sql, dataReaderHandler);
|
52
|
2
|
return handler.Execute(args);
|
53
|
|
}
|
54
|
|
|
55
|
1
|
protected void SetIdentifier(object bean, object value)
|
56
|
|
{
|
57
|
0
|
if(propertyName == null) throw new EmptyRuntimeException("propertyName");
|
58
|
1
|
PropertyInfo propertyInfo = bean.GetType().GetProperty(propertyName);
|
59
|
1
|
propertyInfo.SetValue(bean, Convert.ChangeType(value, propertyInfo.PropertyType), null);
|
60
|
|
}
|
61
|
|
|
62
|
|
#region IIdentifierGenerator メンバ
|
63
|
|
|
64
|
0
|
public virtual bool IsSelfGenerate
|
65
|
|
{
|
66
|
|
get { throw new NotImplementedException(); }
|
67
|
|
}
|
68
|
|
|
69
|
0
|
public virtual void SetIdentifier(object bean, Seasar.Extension.ADO.IDataSource ds)
|
70
|
|
{
|
71
|
|
throw new NotImplementedException();
|
72
|
|
}
|
73
|
|
|
74
|
|
#endregion
|
75
|
|
}
|
76
|
|
}
|
77
|
|
|