Size: a a a

2020 May 21

D

Dima in learn.java
Ivan Korotkii
connection.setAutoCommit(false);
и?
источник

IK

Ivan Korotkii in learn.java
оно запрещает транзакции автоматический исполнять
источник

D

Dima in learn.java
это не влияет на тот факт, что данные уйдут в бд
источник

D

Dima in learn.java
Ivan Korotkii
оно запрещает транзакции автоматический исполнять
и?
источник

ch

central hardware in learn.java
Ivan Korotkii
под рукой нет бд чтобы проверить
Sets this connection's auto-commit mode to the given state. If a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by a call to either the method commit or the method rollback. By default, new connections are in auto-commit mode.
The commit occurs when the statement completes. The time when the statement completes depends on the type of SQL Statement:

For DML statements, such as Insert, Update or Delete, and DDL statements, the statement is complete as soon as it has finished executing.
For Select statements, the statement is complete when the associated result set is closed.
For CallableStatement objects or for statements that return multiple results, the statement is complete when all of the associated result sets have been closed, and all update counts and output parameters have been retrieved.
NOTE: If this method is called during a transaction and the auto-commit mode is changed, the transaction is committed. If setAutoCommit is called and the auto-commit mode is not changed, the call is a no-op.

Parameters:
autoCommit - true to enable auto-commit mode; false to disable it
Throws:
SQLException - if a database access error occurs, setAutoCommit(true) is called while participating in a distributed transaction, or this method is called on a closed connection
источник

D

Dima in learn.java
ты видишь разницу между фиксацией транзации и видимостью другим, и просто отправкой данных в субд в рамках текущей транзации?
источник

Д

Джадив in learn.java
я например вообще не использую ResponseEntity. Если над классом поставить аннотацию @RestController, а в методе-эндпоинте написать return DataClass, где DataClass - простой POJO с полями и геттерами, сеттерами, то JSON будет сформирован из полей класса DataClass. Понятно объснил?
источник

IK

Ivan Korotkii in learn.java
central hardware
Sets this connection's auto-commit mode to the given state. If a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by a call to either the method commit or the method rollback. By default, new connections are in auto-commit mode.
The commit occurs when the statement completes. The time when the statement completes depends on the type of SQL Statement:

For DML statements, such as Insert, Update or Delete, and DDL statements, the statement is complete as soon as it has finished executing.
For Select statements, the statement is complete when the associated result set is closed.
For CallableStatement objects or for statements that return multiple results, the statement is complete when all of the associated result sets have been closed, and all update counts and output parameters have been retrieved.
NOTE: If this method is called during a transaction and the auto-commit mode is changed, the transaction is committed. If setAutoCommit is called and the auto-commit mode is not changed, the call is a no-op.

Parameters:
autoCommit - true to enable auto-commit mode; false to disable it
Throws:
SQLException - if a database access error occurs, setAutoCommit(true) is called while participating in a distributed transaction, or this method is called on a closed connection
For DML statements, such as Insert, Update or Delete, and DDL statements, the statement is complete as soon as it has finished executing.
ну то есть оно ложит на эту переменную получается?
источник

IK

Ivan Korotkii in learn.java
Dima
ты видишь разницу между фиксацией транзации и видимостью другим, и просто отправкой данных в субд в рамках текущей транзации?
как это влияет на присваивание a = число строк?
хотя чет спецификация и тут не очевидна
источник

IK

Ivan Korotkii in learn.java
Ivan Korotkii
For DML statements, such as Insert, Update or Delete, and DDL statements, the statement is complete as soon as it has finished executing.
ну то есть оно ложит на эту переменную получается?
странная переменная если честно
источник

M

Mihhail in learn.java
Джадив
я например вообще не использую ResponseEntity. Если над классом поставить аннотацию @RestController, а в методе-эндпоинте написать return DataClass, где DataClass - простой POJO с полями и геттерами, сеттерами, то JSON будет сформирован из полей класса DataClass. Понятно объснил?
А, допустим, когда надо собрать свой Json ответ? Например, какая-то коллекция и в ней объекты. Это получается, что отдельный класс для коллекции и отдельный для объекта этой коллекции и отдельный класс для сообщения? Так и собирается, да?
источник

M

Mihhail in learn.java
Просто кажется, что немного трудоёмко для простой коллекции создавать отдельный класс, а потом его запихивать в другой класс
источник

M

Mihhail in learn.java
И т.д
источник

M

Mihhail in learn.java
Или это нормальное явление для спринг? :d
источник

M

Mihhail in learn.java
Я просто недавно начал учить это дело. Вот и интересно, как люди делают это в продакшн
источник

M

Mihhail in learn.java
А ещё, кто какие обычно Api guidelines использует ? Или у каждой конторы свой собственные требования?
источник

M

Mihhail in learn.java
А то я смотрю у гугла один гайдлан, у хероку другой, у Амазон тоже свой
источник

M

Mihhail in learn.java
Даже у Белого Дома есть свой гайдлан для Json 😂
источник

Д

Джадив in learn.java
Mihhail
А, допустим, когда надо собрать свой Json ответ? Например, какая-то коллекция и в ней объекты. Это получается, что отдельный класс для коллекции и отдельный для объекта этой коллекции и отдельный класс для сообщения? Так и собирается, да?
приведи пример объектов? и коллекции
источник

IK

Ivan Korotkii in learn.java
central hardware
Sets this connection's auto-commit mode to the given state. If a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by a call to either the method commit or the method rollback. By default, new connections are in auto-commit mode.
The commit occurs when the statement completes. The time when the statement completes depends on the type of SQL Statement:

For DML statements, such as Insert, Update or Delete, and DDL statements, the statement is complete as soon as it has finished executing.
For Select statements, the statement is complete when the associated result set is closed.
For CallableStatement objects or for statements that return multiple results, the statement is complete when all of the associated result sets have been closed, and all update counts and output parameters have been retrieved.
NOTE: If this method is called during a transaction and the auto-commit mode is changed, the transaction is committed. If setAutoCommit is called and the auto-commit mode is not changed, the call is a no-op.

Parameters:
autoCommit - true to enable auto-commit mode; false to disable it
Throws:
SQLException - if a database access error occurs, setAutoCommit(true) is called while participating in a distributed transaction, or this method is called on a closed connection
connection.setAutoCommit(false);

       String sql = "SELECT count(firstname) from baseusers.users where firstname = ? AND lastname = ? AND password = ?";
       System.err.println(sql);

       PreparedStatement statement = connection.prepareStatement(sql);

       statement.setString(1, user.getFirstName());
       statement.setString(2, user.getLastName());
       statement.setString(3, user.getPassword());
       int a = statement.executeUpdate();
       statement.close();
       connection.commit();
а тут выходит бред получается - потому что маны не говорят что будет
источник