I am using MyBatis 2.0.0 and have problem: I have a userId and status field that need to retrieve data so I'm using Mybatis for it.
but when I try to get the data the MyBatis don't work and I keep getting the same error.
I've tried to add the lines to application.properties
#mybatis entity scan packages
mybatis.type-aliases-package=com.cnoga.**.dao
#Mapper.xml location
mybatis.mapper-locations=classpath*:/mybatis/**/*.xml
mybatis.configuration.map-underscore-to-camel-case=true
but nothing happend and I still get my error.
I even tried to create the mybatis-config.xml
like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<setting name="mapUnderscoreToCamelCase" value="true" />
</settings>
</configuration>
and add this line to application.properties instead the lines above:
"mybatis.config-location=classpath:/mybatis-config.xml"
The mapper file:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.proj.user.dao.UserMapper" >
<select id="query4Regist" resultType="java.util.Map" parameterType="java.util.Map" >
select u.user_id userId,
status
from t_user u
left join t_user_group ug on u.user_id = ug.user_id
where u.is_del = 1
and u.status between 0 and 4
and (
u.email = #{account,jdbcType=NVARCHAR}
<if test="countryCode != null and countryCode != ''">
or (u.mobile = #{account,jdbcType=NVARCHAR} and u.country_code = #{countryCode,jdbcType=NVARCHAR})
</if>
)
and (u.region_name = #{regionName} or ug.group_id = 7 or ug.group_id = 8)
order by u.user_id desc offset 0 rows fetch next 1 rows only
</select>
</mapper>
I solved the problem!
The problem was using the map functions.
To use MYBATIS I built struct only for the values I wanted to transfer and I just changed in all the places where I called the map functions to get data from the new struct
Related
I am migrating from ehcache 2 to ehcache 3.5. I am trying to use terracotta open source for sharing the cache with clusters.
Below is my java code,
final CacheManagerBuilder<PersistentCacheManager> clusteredCacheManagerBuilder =
CacheManagerBuilder.newCacheManagerBuilder()
.with(ClusteringServiceConfigurationBuilder.cluster(URI.create("terracotta://terr.com:9410/clustered")).autoCreate()
.defaultServerResource("default-resource")
.resourcePool("pool3", 28, MemoryUnit.MB))
.withCache("boxMaxFileId", CacheConfigurationBuilder.newCacheConfigurationBuilder(String.class, Integer.class,
ResourcePoolsBuilder.newResourcePoolsBuilder()
.with(ClusteredResourcePoolBuilder.clusteredShared("pool3")))) ;
final PersistentCacheManager cacheManager = clusteredCacheManagerBuilder.build(true);
LOGGER.info(cacheManager.getStatus().toString());
return cacheManager;
Can someone help me in getting converted to ehcache.xml
<ehcache:service>
<terracotta:cluster>
<terracotta:connection url="terracotta://terr.com:9410/clustered"/>
<terracotta:server-side-config auto-create="true">
<terracotta:default-resource from="default-resource"/>
<terracotta:shared-pool name="pool1" unit="MB">2</terracotta:shared-pool>
</terracotta:server-side-config>
</terracotta:cluster>
</ehcache:service>
<ehcache:cache alias="boxMaxFileId">
<ehcache:key-type>java.lang.String</ehcache:key-type>
<ehcache:value-type>java.lang.Integer</ehcache:value-type>
<ehcache:resources>
<ehcache:heap unit="entries">100</ehcache:heap>
<ehcache:offheap unit="MB">1</ehcache:offheap>
<terracotta:clustered-shared sharing="pool1" />
</ehcache:resources>
</ehcache:cache>
tc-config.xml
<plugins>
<config>
<ohr:offheap-resources>
<ohr:resource name="default-resource" unit="MB">512</ohr:resource>
</ohr:offheap-resources>
</config>
</plugins>
I am getting exception like Pool name "pool1" not exists in server.
<?xml version="1.0" encoding="UTF-8"?>
<ehcache:config
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:jsr107='http://www.ehcache.org/v3/jsr107'
xmlns:terracotta='http://www.ehcache.org/v3/clustered'
xmlns:ehcache='http://www.ehcache.org/v3'
xsi:schemaLocation="http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core-3.1.xsd
http://www.ehcache.org/v3/jsr107 http://www.ehcache.org/schema/ehcache-107-ext-3.5.xsd
http://www.ehcache.org/v3/clustered http://www.ehcache.org/schema/ehcache-clustered-ext-3.1.xsd">
<ehcache:service>
<terracotta:cluster>
<terracotta:connection url="terracotta://terr.com:9410/clustered"/>
<terracotta:server-side-config auto-create="true">
<terracotta:default-resource from="default-resource"/>
<terracotta:shared-pool name="pool1" from="default-resource" unit="MB">2</terracotta:shared-pool>
</terracotta:server-side-config>
</terracotta:cluster>
</ehcache:service>
<ehcache:cache alias="boxMaxFileId">
<ehcache:key-type>java.lang.String</ehcache:key-type>
<ehcache:value-type>java.lang.Integer</ehcache:value-type>
<ehcache:resources>
<ehcache:heap unit="entries">100</ehcache:heap>
<ehcache:offheap unit="MB">1</ehcache:offheap>
<!-- <terracotta:clustered-dedicated unit="MB">5</terracotta:clustered-dedicated>-->
<terracotta:clustered-shared sharing="pool1" />
</ehcache:resources>
</ehcache:cache>
</ehcache:config>
This is the converted xml. For sharing, we need to use the above format.
I'm working with Spring Jpa Repositories.
I don't want to define my "named queries" in java classes (entities or repositories). I would like to define my "named queries" in different xml files (like orm.xml).
.... XML FILE ....
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence/orm http://xmlns.jcp.org/xml/ns/persistence/orm_2_1.xsd">
<named-query name="MyEntity.findByField1">
<query>
<![CDATA[
SELECT m
FROM MyEntity m
WHERE
m.field1 = :field1
]]>
</query>
</named-query>
</entity-mappings>
.... REPOSITORY CODE ....
public interface MyEntityRepository extends JpaRepository<MyEntity, String>
{
public Optional<MyEntity> findByField1(#Param("field1") String field1);
}
But my repositories are not finding the xml files with my named queries. How do I configure spring-data-jpa to use these xml files? I do not have a persistence.xml.
Thanks!
Since your MyEntity already has field1 property inside using findByField1 as the Repository method name might be confusing. Change the orm.xml as following and place it inside META-INF/orm.xml
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence/orm http://xmlns.jcp.org/xml/ns/persistence/orm_2_1.xsd">
<named-query name="MyEntity.findByField1OrmXml">
<query>
<![CDATA[
SELECT m
FROM MyEntity m
WHERE
m.field1 = :field1
]]>
</query>
</named-query>
</entity-mappings>
And change the Repository as following
public interface MyEntityRepository extends JpaRepository<MyEntity, String>
{
public Optional<MyEntity> findByField1OrmXml(#Param("field1") String field1);
}
May be this question has been asked number of times but I could not figure out the actual solution by going through them. I have a decision table in KIEWorkbench which takes the input from one fact and sets it into another fact. I am trying to call the rules by invoking the endpoint: http://localhost:8085/kie-server-6.4.0.Final-ee7/services/rest/server/containers/instances/pocResult
In the header, I have set the Content-Type as application/xml.
<batch-execution lookup="ksession">
<insert out-identifier="Subject">
<demo.pocFindResult.Subject>
<bCode> ABC</bCode>
<bGCode>XY</bGCode>
<pCode>L0001</pcode>
<subjectType>CA</subjectType>
</demo.pocFindResult.Subject>
</insert>
<fire-all-rules />
<get-objects out-identifier="Result">
<demo.pocFindResult.result/>
</get-objects>
My Decision table is as below:
package demo.pocFindResult;
//from row number: 1
rule "Row 1 findrules"
ruleflow-group "fire-rules"
dialect "java"
lock-on-active true
no-loop true
when
sub : Subject( bCode == "ABC" , bGCode == "XY" , subjectType == "CA" , pCode == "L0001" )
then
Result rs = new Result();
rs.setResultStartDate( "*TODAY" );
rs.setResultEndDate( "*YEAREND" );
rs.setResultContentStartDate( "*TODAY" );
rs.setResultContentEndDate( "*YEAREND" );
insert( rs );
end
How can I get the Result object as the response? Here is my response:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<response type="SUCCESS" msg="Container pocResult successfully called.">
<execution-results>
<results>
<item key="Subject">
<value xsi:type="jaxbListWrapper" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<type>LIST</type>
</value>
</item>
</results>
<facts>
<item key="Subject"/>
</facts>
</execution-results>
</response>
I want the result object with the dates set.
What is the response you get?
I would firstly try to place fire-all-rules tag after your return object. Otherwise, I would try:
<batch-execution lookup="ksession">
<insert out-identifier="Subject">
<demo.pocFindResult.Subject>
<bCode> ABC</bCode>
<bGCode>XY</bGCode>
<pCode>L0001</pcode>
<subjectType>CA</subjectType>
</demo.pocFindResult.Subject>
</insert>
<insert out-identifier="Result" return-object="true" entry-point="DEFAULT">
<demo.pocFindResult.result/>
</insert>
<fire-all-rules/>
</batch-execution>
I am using JBPM 7.0.0-SNAPSHOT and got the same result as yours. When I used the same rules in 6.2.0.Final, I had result back.
EDIT:
The key problem is the header:
Authorization:Basic YWRtaW46YWRtaW4=
Content-Type:application/xml ,
Then I added another header:
"X-KIE-ContentType : XSTREAM"
<batch-execution lookup="defaultKieSession">
<insert return-object="true">
<com.bp.PageContext>
<ID>AID</ID>
</com.bp.PageContext>
</insert>
<insert out-identifier="Group" return-object="true">
<com.bp.GroupData>
</com.bp.GroupData>
</insert>
<insert out-identifier="ERR" return-object="true">
<com.bp.ErrorMessage/>
</insert>
<fire-all-rules/>
<get-objects/>
</batch-execution>
I've got the result back:
<org.kie.server.api.model.ServiceResponse>
<type>SUCCESS</type>
<msg>Container bpcontainr successfully called.</msg>
<result class="execution-results">
<result identifier="Group">
<com.bp,GroupData>
<Code>TEST,QA</Code>
</com.bp.GroupData>
</result>
<result identifier="ERR">
<com.bp.ErrorMessage/>
</result>
<fact-handle identifier="Group" external-form="0:8:567620710:567620710:8:DEFAULT:NON_TRAIT:com.bp.GroupData"/>
<fact-handle identifier="ERR" external-form="0:9:1581854082:1581854082:9:DEFAULT:NON_TRAIT:com.bp.ErrorMessage"/>
</result>
</org.kie.server.api.model.ServiceResponse>
Is it possible to insert new tag in the XML which is there in the XML-database?
For example; below is my example which is exists in the database:
<PurchaseOrder
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"http://localhost:8080/source/schemas/poSource/xsd/purchaseOrder.xsd">
<Reference>SBELL-2002100912333601PDT</Reference>
<Actions>
<Action>
<User>SVOLLMAN</User>
</Action>
</Actions>
<Reject/>
<Requestor>Sarah J. Bell</Requestor>
<User>SBELL</User>
<CostCenter>S30</CostCenter>
<SpecialInstructions>Air Mail</SpecialInstructions>
<LineItems>
<LineItem ItemNumber="1">
<Description>A Night to Remember</Description>
<Part Id="715515009058" UnitPrice="39.95" Quantity="2"/>
</LineItem>
</LineItems>
</PurchaseOrder>
I need to insert new tag <sender>xxxx</sender> where <costCente> is 'S30'.
After inserting/updating the XML, it should be like below:
<PurchaseOrder
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"http://localhost:8080/source/schemas/poSource/xsd/purchaseOrder.xsd">
<Reference>SBELL-2002100912333601PDT</Reference>
<sender>xxx</sender>
<Actions>
<Action>
<User>SVOLLMAN</User>
</Action>
</Actions>
<Reject/>
<Requestor>Sarah J. Bell</Requestor>
<User>SBELL</User>
<CostCenter>S30</CostCenter>
<SpecialInstructions>Air Mail</SpecialInstructions>
<LineItems>
<LineItem ItemNumber="1">
<Description>A Night to Remember</Description>
<Part Id="715515009058" UnitPrice="39.95" Quantity="2"/>
</LineItem>
</LineItems>
</PurchaseOrder>
Is it really a possible scenario?
Can any one give me query to do this, if it is possible.
Thanks in advance.
Below query worked for me.
UPDATE TABLENAME dd SET dd.object_value =
insertXMLbefore(dd.object_value,
'/c:PurchaseOrder/c:Reference',
XMLType('<d:sender xmlns:d="http://www.w3.org/2001/XMLSchema-instance">XXXX</d:sender>'),
xmlns:c="http://www.w3.org/2001/XMLSchema-instance"')
WHERE dd.id in (SELECT dd.id FROM TABLENAME dd,XMLTable(XMLNAMESPACES(
DEFAULT 'http://www.w3.org/2001/XMLSchema-instance' AS "c"),
'/PurchaseOrder' PASSING dd.object_value COLUMNS sender VARCHAR2(8 CHAR) PATH 'c:PurchaseOrder/c:Reference/text()',
rp VARCHAR2(8 CHAR) PATH 'CostCenter/text()') li
WHERE sender is null and rp = 'S30');
I have created a scenario by creating a myScenario.sdl in my local config folder /atg/registry/data/scenarios/myScenario.sdl
myScenario.sdl
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE process SYSTEM "dynamosystemresource:/atg/dtds/pdl/pdl_1.0.dtd">
<process author="admin" creation-time="1413804041263" enabled="false" last-modified-by="admin" modification-time="1413804191188">
<segment migrate-subjects="true">
<segment-name>ItemAddedToOrder</segment-name>
<!--================================-->
<!--== Item added to order Quantity with fraction is defined -->
<!--================================-->
<event id="1">
<event-name>atg.commerce.order.ItemAddedToOrder</event-name>
<filter construct="event-property-filter" operator="isNotNull">
<event-property construct="event-property">
<property-name>quantityWithFraction</property-name>
</event-property>
</filter>
</event>
<!--================================-->
<!--== Log a message message: Quantity With Fraction is Defines logTriggeringEvent: true -->
<!--================================-->
<action id="2">
<action-name>Log a message</action-name>
<action-param name="message">
<constant>Quantity With Fraction is Defines</constant>
</action-param>
<action-param name="logTriggeringEvent">
<constant type="java.lang.Boolean">true</constant>
</action-param>
</action>
</segment>
</process>
And enabled the scenario:
Registry scenarioRegistry = scenarioManager.getScenarioRegistry();
byte[] data = (byte[]) scenarioRegistry.getItem(pScenarioPath);
String xml = null;
if (data != null) {
xml = new String(data, "UTF-8");
} else {
Assert.fail("No scenario is existed to enable/disable");
}
String updatedXml;
if (scenarioState && xml != null) {
updatedXml = xml.replaceAll("enabled=\"false\"", "enabled=\"true\"");
} else {
updatedXml = xml.replaceAll("enabled=\"true\"", "enabled=\"false\"");
}
scenarioRegistry.putItem(pScenarioPath, updatedXml.getBytes("UTF-8"));
Now with this above written code, I can both disable or enable the scenario by changing the state as false and true respectively. But I want to delete the scenario(please remember, my requirement is DELETE not DISABLE SCENARIO). I know using scenarioManager.updateScenario() deleted the scenario. Is my understanding right?
One more thing, I know I can delete the scenario directly from ACC. But I need to code via code not manually from ACC.
Please share your thoughts!
Did you try scenarioRegistry.removeItem(path);