Remove specific select id data from MyBatis cache - mybatis

<mapper namespace="src.main.domain.EqMapper">
<cache eviction="FIFO" size="512" readOnly="true"/>
<select id="getStoreIdAndEqId" resultType="String" flushCache="false" useCache="true">
select count(author) from blog
</select>
<select id="getWholeData" resultType="java.util.LinkedHashMap" flushCache="false" useCache="true">
select * from blog
</select>
</mapper>
Configuration configuration = MyBatisUtil.getSqlSessionFactory().getConfiguration();
Collection<Cache> caches = configuration.getCaches();
for (Cache cache : caches) {
Lock w = cache.getReadWriteLock().writeLock();
w.lock();
try {
cache.clear();
} finally {
w.unlock();
}
}
The above cache logic clears all cache. Is it possible to clear a specific cache? I want to delete getStoreIdAndEqId cache and not getWholeData cache.

Try this:
<select id="getStoreIdAndEqId" resultType="String" flushCache="true" useCache="false">
select count(author) from blog
</select>
<select id="getWholeData" resultType="java.util.LinkedHashMap" flushCache="false" useCache="true">
select * from blog
</select>

Related

insert data if not exist in the column using Laravel elequant

I'm developing a doctor's appointment laravel project. the condition is if a user fixes an appointment they can't able to fix the appointment for the same doctor at the same date and time. I tried with firstOrCreate method but doesn't match my condition. here are my conditions
1.if doctors_id AND date AND time already exist then shouldn't insert the data
2.if doctors_id OR date OR time, any three of this already exist then can insert the data
3.if all fields already not exist then insert data
here are the code snippets
In view
<div class="card-body">
<form action="appointment" method="post">
{{ #csrf_field() }}
<select name="doctors" id="" class="form-control">
#foreach ($docList as $item)
<option value="{{$item->id}}">{{$item->name}}</option>
#endforeach
</select><br><br>
<input type="date" name="date" id="" class="form-control">
<br><br>
<select name="time" class="form-control">
<option value="9-10AM">9-10AM</option>
<option value="10-11AM">10-11AM</option>
<option value="1-2PM">1-2PM</option>
<option value="2-3PM">2-3PM</option>
<option value="3-4PM">3-4PM</option>
</select>
<button type="submit" class="btn btn-primary">Fix Appointment</button>
</form>
</div>
In controller
public function store(Request $request)
{
$uId = Auth::id();
$fixAppointment = Appointment::firstOrNew(['doctors_id'=>$request->doctors,'date'=>request('date')],['time'=>request('time')]);
$fixAppointment->users_id = $uId;
$fixAppointment->save();
}
Here I sorted out the issue by using where condition
In controller
$appointment = Appointment::where('date', '=', request('date'))->where('time','=',request('time'))->where('doctors_id','=',request('doctors'))->first();
if ($appointment === null)
{
$fixAppointment = New Appointment;
$fixAppointment->doctors_id = $request->doctors;
$fixAppointment->users_id = $uId;
$fixAppointment->date = $request->date;
$fixAppointment->time=$request->time;
$fixAppointment->save();
}
here is the link which I referred to find this solution.

Angular2 reactive forms select how to set invalid?

I use reactive forms within my app. In a certain form I want to display a required (Validators.required) select like this:
<select class="form-control"
[id]="dformControl.key"
[formControlName]="dformControl.key"
[multiple]="dformControl.multiple">
<option *ngIf="!dformControl.value"
value="undefined">
Choose ...
</option>
<option *ngFor="let opt of dformControl.options"
[value]="opt.value"
[selected]="dformControl.value == opt.value">
{{opt.label}}
</option>
</select>
The problem is whether I use value="undefined" or value="" the form control still is set to valid because it got a value. Do not present the value attribute results in value="Choose ...".
Am I using select with reactive forms in a false way or how would I be able to make the option "Choose ..." being not valid??
Assigning initial value of select control to null will do the trick. Try below,
model_property = null
....
this.fb.group({
....
'control_key' : [this.model_property, Validators.required]
...
})
Check this Plunker!!, Look into app/reactive/hero-form-reactive.component.ts file.
I updated the Plunker to include below and it seems to be working,
<select id="power" class="form-control"
formControlName="power" required >
// see the value is set to empty,
<option value="">Choose...</option>
<option *ngFor="let p of powers" [value]="p">{{p}}</option>
</select>
Hope this helps!!
What I do is add a blank option and when that is selected since there is no value it is not valid.
<select class="form-control"
[id]="dformControl.key"
[formControlName]="dformControl.key"
[multiple]="dformControl.multiple">
<option></option>
<option *ngFor="let opt of dformControl.options"
[value]="opt.value"
[selected]="dformControl.value == opt.value">
{{opt.label}}
</option>
</select>

Change form action according to select option

I have a simple form:
<form name="simple" id="simple" method="post" action="X.php">
<select name="select">
<option value="none"> Select </option>
<option value="1">1st</option>
<option value="2">2nd</option>
<option value="3">3rd</option>
</select>
</form>
I want X (X.php) to change with option values.
For example, when user selects 1st, it should change to 1.php.
Is it possible?
Yes you can, example with jquery is as follows:
$("#selectID").change(function() {
var action = $(this).val();
$("#simple").attr("action", action + ".php"); // Can also use .prop("action", action + ".php");
});

React, can't select the first option of <select>

I render a <select> box in react from an array. My array looks like this:
options: [
{"id":1,"name":"Option1"},
{"id":2,"name":"Option2"},
{"id":3,"name":"Option3"}
];
I map the array and find all the options, then I render the options inside the map. However I'm able to select whatever option from the select, except the first one.
Here's my select:
<select
className="form-control"
name={this.props.name}
onChange={this.handleChange.bind(this)}>
{(Array.isArray(this.props.options) && this.props.options.length > 0) ? this.props.options.map(option => {
return (
<option key={option.id} value={option.id}>{option.name}</option>
)
}) : (<option>No Options Found</option>)}
</select>
How do I do it, to be able to select the first option as well? What am I doing wrong?
Your first option is selected by default. If you want - you can create an empty option and after that you can select first option.
render() {
const options = this.props.options.map(option =>
<option key={option.id} value={option.id}>{option.name}</option>
)
return (
<select
className="form-control"
name={this.props.name}
onChange={this.handleChange.bind(this)}
>
<option value="">Select option</option>
{options}
</select>
)
}
add a default line before your options
<option>select size</option>
quickview_product.map(itm => <option value={itm.label}>{itm.label}</option>)

How to add nofollow to drop down

I have a drop down list which filters category ASC and DESC. Google doesn't seem to understand that is duplicate content. How can I prevent Google from not following the drop down selections:
<select>
<select class="sort-by-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;" name="ssort">
<option onclick="window.location = "http://mysite.com/category1/sort/_post_name-pp-asc/"; return false;" selected="" value="http://mysite.com/category1/sort/_post_name-pp-asc/">Name ASC</option>
<option onclick="window.location = "http://mysite.com/category1/sort/_post_name-pp-desc/"; return false;" value="http://mysite.com/category1/sort/_post_name-pp-desc/">Name DESC</option>
</select>
Pretty sure rel="nofollow" only works within <a> tags.
Don't think it will work with a window.location