"Java seconds technology seconds to kill interviewers" common face Test (v)

Source: Internet
Author: User
Tags serialization

51. What are the characteristics of a transaction?

Answer: ① atomicity (atomicity)

A transaction is an indivisible unit of work in which the operation of a transaction either occurs or does not occur;

② Consistency (consistency)

The completion of the data before and after the transaction must be consistent; (ex: Before and after the transfer, the total amount of two persons is unchanged)

③ Isolation (Isolation)

When multiple users access the database concurrently, the transaction of one user cannot be disturbed by other users ' transactions, and multiple concurrent transactions are quarantined.

④ Persistence (Durability)

When a transaction is committed, its changes to the data in the database are permanent, and the subsequent failure of the database should not have any effect on it;

52. Issues with concurrent access to transactions?

A: ① dirty reads: One transaction reads uncommitted data from another transaction;

② cannot be read repeatedly: In the same transaction, the results of multiple queries are inconsistent (caused by the update)

③ read/Phantom read: In the same transaction, the results of multiple queries are inconsistent (caused by insert)

53. Level of isolation?

Answer: ① Read not submitted

READ UNCOMMITTED; One transaction reads to another transaction without committing the data;

(Not resolved, 3 issues exist)

② Read Committed--oracle default

Read Committed; One transaction reads the data that has been committed by another transaction;

(Fix dirty Read)

③ REPEATABLE READ---mysql default

Repeatable read; The data that reads in one transaction is always consistent regardless of whether another transaction is committed

(Resolve dirty Read and non-repeatable read)

④ serialization

Serializable serialization, at the same time can only execute one transaction, equivalent to single-threaded transaction;

(both resolved)

54.tuncate and delete difference?

Answer: ①truncate data DDL delete belongs to DML

②truncate is to delete the table before the drop, and then create the table. and can't roll back!!!

55.5 ways to implement data retrieval in Hibernate?

Answer: ① object Navigation (data retrieval at association level)

②HQL statements

③sql statements

④QBC statements

⑤ loaded via OID (get ()/load ())

What is the difference between 56.Cascade and inverse?

A: ①cascade is mainly used for cascade operations (such as: Cascade Add, delete, etc.);

②inverse is mainly used to control whether the right to reverse, generally control right in the multi-party, can improve efficiency;

For example: When deleting a department, Cascade deletes all users under the department.

若inverse = “false” 默认值,可以不配

Console Output 3 statements:

Update user Set deptid = null where deptid = 1;//resolves parent-child relationship

           Delete from user where deptId is null; //先干掉子类           Delete from user where id=1; //再自杀若inverse = “true” 代表控制权要反转,交给多方维护,相率会提高;   控制台输出2条语句:           Delete from user where deptId=1; //自杀           Delete from user where id=1;//自杀

What is the definition specification for the 57.PO class?

Answer: ① is a common class;

② provides the method of common construction without parameters;

The ③ property is private;

④ provides a common getter/setter for private attributes;

⑤ cannot use final decoration;

⑥ can implement Java.io.Serializbale interface;

⑦ if it is a basic type, it needs to use its wrapper class;

58. Write a one-to-many, multi-pair, many-to-many PO class mapping file, respectively?

59. What are the reasons for extracting baseaction?

A: ① by implementing Requestaware, Sessionaware, applicationaware interfaces, customizing protected Map request/session/application, and providing getter methods, Inherit setter method, at this time, then write the action class, rely on their own API, in the future when the framework upgrade, as long as the modification of baseaction can be better to achieve the STRUTS2 with the solution coupling;

② can extract some common operation methods in the Baseaction;

What are the 60.XML document definitions in several forms? What are the essential differences between them? What are the different ways to parse an XML document?

A: (1) XML documents have two kinds of constraints: DTD constraints and schema constraints;

(2) Difference:

①DTD does not conform to the syntax structure of XML, schema conforms to the syntax structure of XML;

The constraint extensibility of ②DTD is poor, and XML documents can only introduce one DTD file. Schema can introduce multiple files;

③DTD does not support namespaces (understanding package structure), schema supports namespaces;

④DTD support data is relatively small, schema supports more data types;

(3) There are three main ways of parsing:

①dom parsing:

(a) loading the entire XML document into memory, forming a tree structure and generating objects;

(b) easy to generate memory overflow;

(c) Additions and deletions may be made;

②sax parsing

(a) reading edge parsing;

(b) No additions or deletions can be made;

③DOM4J parsing (Hibernate bottom-up adoption)

(a) allows Sax parsing to also produce a tree structure.

(b) Main API development steps:

1) Saxreader.read (Xxx.xml) represents the document parsing the XML, and the returned object is documents;

2) document.getrootelement (), returns the root node of the document, is the element object;

3) Element:

. Element (...)--Gets the first child element of the specified name. Can not specify a name;

. elements (...)--gets all child elements of the specified name. Can not specify a name;

.getText() -- 获得当前元素的文本内容;

. Elementtext (...)--Gets the text value of the specified name child element

. AddElement ()--Add child nodes

. SetText ()--Set sub-label contents

4) Xmlwriter.write ("..")--write

5) Xmlwriter.close ()--close the output stream

61. Why do you use MAVEN to build your project?

A: ① first, MAVEN is an excellent project building tool. With Maven, it's easy to build a project in a modular way, so you can improve productivity when you develop and test packaged deployments.

② second, MAVEN can manage dependencies. With Maven, the dependencies of different systems can be managed uniformly and can be passed and inherited between dependencies.

"Java seconds technology seconds to kill interviewers" common face Test (v)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.