Tag Archives: solution

org.springframework.orm . hibernate3. Hibernatequeryexception: XXX is not mapped solution

There are several reasons as follows:
1

1. The HBM file association in spring is not configured well.

2. The fields in the HBM file are missing.

Solution:

1. Add fully qualified domain name when writing HQL (not recommended)

2. Configure HBM Association in spring (20 has been like this for several times)
in this paper, we introduce a new method to configure HBM Association in spring

When Tomcat starts: IOException while loading persistent sessions: java.io.EOFException Solutions for

This is due to the fact that when Tomcat was shut down abnormally last time, some active sessions were persisted (as some temporary files). When it was restarted, Tomcat tried to recover the persistent data of these sessions, but failed to read them. This exception does not affect the use of the system.

Solution: all the files in Catalina directory can be deleted.
all the files in Catalina directory can be deleted

Solution to report undefined a error when using jquery

When the project uses easyUI, the foreground reports an error, type error: A is undefined. I see that the error location is actually the source code of JQ… It’s impossible. I searched a lot of information on the Internet, but I didn’t solve the problem. After nearly a month’s thinking, I seem to have found the cause of this problem. It may not be right. It only represents personal profile. If there is a positive solution, please let me know. Thank you.

The error screenshot is as follows:

The reasons are as follows: I have such a piece of code in JS:

 $('#cargo_info').datagrid().datagrid('getPager');

Note that this code is not put in any function, nor is it wrapped with $(function () {}). Just this sentence is put directly in JS code. This is all the cases that report this error in my project. My preliminary analysis is because JS thinks that there is no method to call this sentence, so it reports an error.

Solution: wrap the isolated statements in JS with $(function () {}), or write them in a function,

<pre name="code" class="javascript">$(function(){
    $('#cargo_info').datagrid().datagrid('getPager');
})


Like this, you can’t make a mistake at the front desk

Solution of toast not displaying in Android

Today, in the test, toast could not be displayed. I analyzed several possibilities

1. There is a problem with the context. The corresponding context may be incorrect

2. The value of message is null

But I checked it several times and there was no problem…. Looking up information on the Internet, I said that I couldn’t update UI in sub thread, but I didn’t open thread… After a night of silence. I found the problem. After using toast, I didn’t call the show method… That’s why I don’t show it. It’s too sloppy…

Solution to the problem of multiple parameters when using pipeline under Linux

When doing the project today, we encountered a problem, that is, how to use the pipeline under the Linux command. We will certainly use the simple pipeline, just like this form

<span style="font-size:18px;">ls -a | grep *test</span>

Today’s problem is a bit complicated. It is to scan the system log in real time, from the last line after scanning to the end of the file, and match keywords. If they match, an alarm will be given. I use awk with grep command to achieve

Awk command is used to select log segment output as the input of grep command

awk 'NR>= beginLineNum&& NR<endLineNum logFileName  | grep -nE  pattern ;

But how to get the total row number of the current log becomes a problem. The command to get the total row number is

wc -l logFileName

But the result after WC is to be placed in the position of Ender linenum, which can not be realized by | method. After query, it is found that it can be realized by using the ‘` symbol (` symbol is the key under the ESC key on the keyboard)

So the way to do it is

awk 'NR>= beginLineNum&& NR<`wc -l logfileName` logFileName  | grep -nE  pattern ;

When executing commands in Linux, the commands in ‘will be executed first, and then other commands will be executed

“As standard input, the return value of the command inside is input into the command outside.

When MyEclipse starts tomcat, the console doesn’t jump out

Today, I encountered a problem. Originally, when I started Tomcat through MyEclipse, the tab would automatically jump to the console to display some startup logs, but I couldn’t jump today, as shown in the figure below

The reason is due to the problem of setting, there are two solutions

1、

As shown in the figure above, click on the chart as shown in my picture.

2. Click windows – & gt; preferences – & gt; run/debug – & gt; console

Check the two show’s beginning, and it’s OK.

Just choose one of the two methods above. After setting, you can see that when we start tomcat, the next tab will automatically jump to console

An unable to locate appropriate constructor on class solution appears

Today, when using hibernate operation, the query operation also made this error. I couldn’t figure out the solution. Finally, I found the ending method on the Internet, which should not be regarded as the method. That’s the reason.

First, I use the following HQL statement

String hql="select new PO(。。。。) from 。。。";

This error is largely due to the time format. The reasons are as follows

1. In Oracle, what is the return time of using hibernate query java.util.Date Yes.

2. When using struts1, the time plug-ins in the foreground must be string in the form, otherwise an error will be reported.

3. Use BeanUtils.copyProperties Method, the string time in form can only be converted to java.sql.Date Type.

4. Due to the reason of 3, the time type of Po entity class should be java.sql.Date Type.

5. Oracle return java.util.Date , Po is java.sql.Date So the problem arises.

The current solution is to transform in the construction method, and another method is to implement string to java.util.Date But what I’m doing now is an old project. There was a lot of code before, and it would be troublesome if I made a mistake. So it’s relatively safe to use the construction method to convert.

We have to make complaints about the problems in our project, which are basically caused by the time type related to the database, and the conflict of jar packages in the project.

The solution of Hibernate query returning all null lists

Today, when I was working on a project, I used HQL to look up the database, but all the returned results were null. Note that the returned list is not null, but there are values in the list. The size of the list is the total number of records, but when I traverse the list output, all the elements in the list are null. I suspect that there is something wrong with my conditions. I have removed all the conditions, leaving only one sentence:

String hql = "from CarMaintain t";

It’s worth the rest of the sentence, but it’s still the result. I searched the information on the Internet, and all of them were wrong answers. Without exception, I said it was impossible… Then how did I meet… Others are unreliable, so we have to find our own problems.

I began to analyze, why only this sentence has this situation, and other sentences are OK?I found that the table in question has no primary key. Yes, that’s the reason. When there is no primary key, hibernate’s reverse engineering will automatically construct a composite primary key for us, so I started to check hbm.xml The file and configuration are correct. What’s the problem?I collapsed all afternoon for it. The reason is due to the internal mechanism of hibernate,

In my table without primary key, the fields in the composite primary key constructed by hibernate have null values, so no matter how you look it up, it is null in the end. When you break the point, you will see [null, null, null,….]

resolvent:

1. Create a new field, use it as the primary key, and hbm.xml The file is modified correctly

2. All fields contained in the composite primary key cannot be null in the database

It took a long time to solve this problem. I hope I can help you.

Solution: windowserror: [error 2]

There is a problem when renaming a file by using the rename() function of python, which prompts windows error: [error 2]. The initial code is as follows:

def renameFile(filename):
    filePre = "D:\\FileDemo\\Python\\pt.py"
    os.rename(filePre, filename)
    print os.listdir(filePre)

if __name__ == '__main__':
    fileNew = "D:\\FileDemo\\Python\\Test.py"
   renameFile(fileNew)

Later, after repeated attempts, the problem was solved~

Before rename, you need to use the chdir() function to enter the path of the target file to tell the python compiler where the file to be renamed is, and then you can modify it;

Python is not a terrible terminator. In fact, she is very young. She can’t find the file herself. We need to tell her where to find the path in detail and patiently os.path.dirname () function

import os
from nt import chdir

def renameF(preName, newName):
    chdir(os.path.dirname(preName))
    os.rename(preName, newName)

if __name__ == '__main__':
    filePre = "D:\FileDemo\Python\PT.py"
    fileNew = "D:\FileDemo\Python\Test.txt"
    renameF(filePre, fileNew)

The code is very simple. You can rename any file by modifying filepre and FileNew.

TSC: Fast TSC Calibration Failed solution

For workstations

tsc : Fast TSC calibration failed

smpboot : do_boot_cpu failed(-1) to wakeup CUP#N

Error reporting shall be handled as follows:
Press F11 to enter the BIOS mode (keys may be different for each machine), set the setting to set default, save the changes and restart, the machine can restart.

Perfect solution Error:Execution failed for task ‘: APP:transformClassesWithDexForDebug ‘… Problem

believe that everyone in the Android development can not avoid to be integrated in the process of the third party after a project, integration, sometimes it will encounter this ash often hate transformClassesWithDexForDebug, detailed Log is as follows:


Error:Execution failed for task ':APP:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException

The main reason for this problem is that the introduction of Libary overlaps with some Libs in existing projects. Please check in detail and make sure that there is only one copy of lib in use, such as v4, v7, utdid.jar, etc.

if you use other android’s official support library see, http://developer.android.com/tools/support-library/features.html

if there is still a problem after the above situation check, you can try to use the following configuration to solve the problem

defaultConfig {
    ...
    minSdkVersion 14
    targetSdkVersion 21
    ...

    //Enabling multidex support.
    multiDexEnabled true
}
dependencies {
    compile ´com.android.support:multidex:1.0.1´
}


and then in the manifest we introduce this, if there is a custom AppApplication, let your own AppApplication inherit this class

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.multidex.myapplication">
    <application
        ...
        android:name="android.support.multidex.MultiDexApplication">
        ...
    </application>
</manifest>

may also be a JDK version 1.8 problem, which is not an accident, so suspect that Gradle has compatibility problems with JDK 1.8 and try to reduce the number of JDK dependencies to 1.7

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

can be run or there will be errors after the configuration is completed, so we can also add this sentence in app.bulid and re-run after that. The specific amount or 4g can be seen from the computer configuration modification (2g, 3g, 6g, 8g).

dexOptions {
    javaMaxHeapSize "4g"
}

the above is the Error: I met in the Execution failed for task ‘: APP: transformClassesWithDexForDebug’ all solutions, sharing out hope to help everyone.


Javabinder:

JavaBinder: !!! FAILED BINDER TRANSACTION !!! Solution analysis for exceptions

is the cause of

I have been in charge of the development of the company’s mobile multimedia app. Recently, I was in charge of A project: in an Activity, I read the picture files in the external usb disk and encapsulated them as

public class MediaFileBean implements Serializable {
private static final long serialVersionUID = 1L;
private String name = "";
private String time = "";
private String path = "";
private Bitmap bitmap;//图片第一帧,即缩略图
private String fileName = "";
private int isLove = -1;
private FileFormat fileFormate;
private String sortLetters;

    ......
}

and display thumbnails in a list, when you click on the display image, pass all the data to B (dedicated to display the image) :

AActivity.java:
private void enterBActivity(ArrayList<MediaFileBean> mPhotoList, int position) {
    Intent intent = new Intent(mActivity, BActivity.class);
    intent.putExtra(Constants.PHOTO_ITEM_LIST, mPhotoList);//将扫描出来的图片文件传递给B
    intent.putExtra(Constants.PHOTO_CURRENT_POSITION, position);
    startActivity(intent);
}

B receives data from A:

//onCreate()中调用initData()
public void initData() {
    ......
    mPhotoList = (ArrayList<MediaFileBean>) getIntent().getSerializableExtra(Constants.PHOTO_ITEM_LIST);
    currentPosition = getIntent().getIntExtra(Constants.PHOTO_CURRENT_POSITION, -1);
    ......
}

but if the usb disk contains a lot of pictures, no matter how point, is not into the B page, the program does not crash, background print logcat, found JavaBinder:!!! FAILED BINDER TRANSACTION !!! Error

cause of occurrence

online search, the general reason is that the Bitmap should not be more than 40KB for data delivery with intents. According to the official website, data delivery with intents is limited, the maximum size is about 1M

solution

1. Try not to pass the Bitmap in intents. saves the bitmap to be passed in the SD, instead of the url in the Intent.

2. If you really want to pass the Bitmap, to its compression

`/**
 * 压缩图片
 * 该方法引用自:http://blog.csdn.net/demonliuhui/article/details/52949203
 * @param image
 * @return
 */
public static Bitmap compressImage(Bitmap image) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    image.compress(Bitmap.CompressFormat.JPEG, 100, baos);//质量压缩方法,这里100表示不压缩,把压缩后的数据存放到baos中
    int options = 100;
    while (baos.toByteArray().length/1024 > 100) {  //循环判断如果压缩后图片是否大于100kb,大于继续压缩
        baos.reset();//重置baos即清空baos
        image.compress(Bitmap.CompressFormat.JPEG, options, baos);//这里压缩options%,把压缩后的数据存放到baos中
        options -= 10;//每次都减少10
    }
    ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray());//把压缩后的数据baos存放到ByteArrayInputStream中
    Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, null);//把ByteArrayInputStream数据生成图片
    return bitmap;
}`

3. data to be passed to the global variable

is not helpful if you have a large amount to pass. In my example above, even if I remove the bitmap variable from the bean, I still get an error because the array I’m passing is too large! Another way to think about it is that the data to be passed will be placed in a fixed value in the life cycle and assigned to value at any time. When you think about it, it is appropriate to put it in the Application:

public class MediaApplication extends Application {
    // 用于传递的图片数据
    private List<MediaFileBean> mPhotoList;
    private static MediaApplication mInstance;
    @Override
    public void onCreate() {
        super.onCreate();
        mInstance = this;
    }

    public synchronized static MediaApplication getInstance() {
        return mInstance;
    }

    public void setPhotoList(ArrayList<MediaFileBean> list){
        this.mPhotoList = list;
    }

    public List<MediaFileBean> getPhotoList(){
        return this.mPhotoList;
    }

}

when A jumps to B:

private void enterBActivity(ArrayList<MediaFileBean> mPhotoList, int position) {
    MediaApplication.getInstance().setPhotoList(mPhotoList);
    Intent intent = new Intent(mActivity, BActivity.class);
    intent.putExtra(Constants.PHOTO_CURRENT_POSITION, position);
    startActivity(intent);
}

B received A data:

@Override
public void initData() {
    mPhotoList = (ArrayList<MediaFileBean>) MediaApplication.getInstance().getPhotoList();// 解决异常:JavaBinder: !!! FAILED BINDER TRANSACTION !!!
    currentPosition = getIntent().getIntExtra(Constants.PHOTO_CURRENT_POSITION, -1);
}