我正在使用OrientDB,认为它的orient-jdbc驱动程序。
我有一个表存储应用程序属性,我们称之为TABLE_PROPERTIES,有两个字段CONFIG_KEY和CONFIG_VALUE。
存储在数据库中的属性会覆盖存储在属性文件中的属性。
要做到这一点,我正在使用Commons Configuration 2。
配置(在Spring xml中)非常简单:
<bean id="dataSource" class="com.orientechnologies.orient.jdbc.OrientDataSource" depends-on="embeddedDatabase">
<constructor-arg name="url" value="jdbc:orient:plocal:xxx\\orientdb\\databases\\test" />
<constructor-arg name="username" value="xx"/>
<constructor-arg name="password" value="xx"/>
<constructor-arg name="info" ref="props" />
</bean>
<bean id="props" class="java.util.Properties" >
<constructor-arg>
<props>
<prop key="db.usePool">false</prop>
</props>
</constructor-arg>
</bean>
<context:property-placeholder location="classpath*:**/*.properties" properties-ref="configurationPropertiesFactoryBean"/>
<bean id="configurationPropertiesFactoryBean" class="org.apache.commons.configuration2.spring.ConfigurationPropertiesFactoryBean">
<constructor-arg ref="databaseConfiguration"/>
</bean>
<bean id="databaseConfiguration" class="org.apache.commons.configuration2.DatabaseConfiguration">
<property name="dataSource" ref="dataSource"/>
<property name="table" value="TABLE_CONFIG"/>
<property name="keyColumn" value="CONFIG_KEY"/>
<property name="valueColumn" value="CONFIG_VALUE"/>
<property name="configurationName" value="testPropertiesConfiguration" />
</bean>
我收到了这个错误:
Caused by: com.orientechnologies.orient.core.sql.OCommandSQLParsingException: Error parsing query:
SELECT DISTINCT CONFIG_KEY FROM TABLE_CONFIG WHERE 1 = 1
^
Encountered " <IDENTIFIER> "CONFIG_KEY "" at line 1, column 17.
Was expecting one of:
<EOF>
<LIMIT> ...
<SKIP2> ...
<OFFSET> ...
<TIMEOUT> ...
<AS> ...
<FETCHPLAN> ...
<LOCK> ...
<LET> ...
<NOCACHE> ...
<PARALLEL> ...
<UNWIND> ...
";" ...
"," ...
<AS> ...
"," ...
DB name="test"
at com.orientechnologies.orient.core.sql.parser.OStatementCache.throwParsingException(OStatementCache.java:98)~
该错误也很容易解释,因为它与OrientDB SQL有关。
这在OrientDB SQL中无效:
SELECT DISTINCT CONFIG_KEY FROM TABLE_CONFIG WHERE 1 = 1
这是有效的:
SELECT DISTINCT (CONFIG_KEY) FROM TABLE_CONFIG WHERE 1 = 1
基本上,DISTINCT关键字需要字段之间的圆角。
有谁知道一种优雅而有效的方法来解决这个问题?