First, <dynamic><isNotNull>
<!--Select Basic Statement - <SelectID= "Tbhyscenariosetting.select"Parameterclass= "Tbhyscenariosettingdomain"ResultClass= "Tbhyscenariosettingdomain">select ID as ID, gmt_create as gmtcreate, gmt_modified as Gmtmodified, scenario_name as S Cenarioname, Layout_type as Layouttype, industry_id as Industryid, creator as creator, Modifie R as modifier, max_item_per_category as Maxitempercategory, Max_item_per_seller as Maxitemperseller, Max_item_per_brand as Maxitemperbrand, MAX_ITEM_PER_SPU as MAXITEMPERSPU, scene_id as Sceneid from TB hy_scenario_setting where 1=1<Dynamic> <Isnotnull Property= "Sceneid"prepend= "and">scene_id= #sceneId #</Isnotnull> <Isnotnull Property= "id"prepend= "and">id= #id #</Isnotnull> </Dynamic> </Select>
1) If the ID field is not NULL, add "and" before the Isnotnull label statement.
2) The <dynamic> tag overrides the prepend in the sub-label, and the,<dynamic> in the previous example has no prepend, so the and in the sub-label is retained.
The usage here is where 1=1, then dynamic SQL.
You can also <dynamic prepend = "where" so that you can override and in the child tag to make it where.
second, [email protected] @Identity
<!--INSERT INTO basic statement - <InsertID= "Tbhyscenariosetting.insert"Parameterclass= "Tbhyscenariosettingdomain">INSERT INTO tbhy_scenario_setting (scene_id,gmt_create,gmt_modified,scenario_name,layout_type,industry_id, CREATOR,MODIFIER,MAX_ITEM_PER_CATEGORY,MAX_ITEM_PER_SELLER,MAX_ITEM_PER_BRAND,MAX_ITEM_PER_SPU) VALUES (#sceneId #,now (), now (), #scenarioName #, #layoutType #, #industryId #, #creator #, #modifier #, #maxItemPerCategory #,# maxitemperseller#, #maxItemPerBrand #, #maxItemPerSpu #); <SelectkeyResultClass= "Long"Keyproperty= "id">SELECT @ @identity as ID</Selectkey> </Insert>
Use the [email protected] @Identity to get the new record ID.
Use:
Public Tbhyscenariosettingdomain Add (final tbhyscenariosettingdomain domain) { return ( Tbhyscenariosettingdomain) Transactiontemplate.execute (new transactioncallback () { @Override Public Object dointransaction (transactionstatus status) { = (Long) getsqlmapclienttemplate (). Insert (" Tbhyscenariosetting.insert ", domain); Domain.setid (ID); Addscenetopicsandtabs (domain); return domain;}} ); }
To be Continued