This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I have:
INSERT INTO employee (id, name) VALUES (0, null);
INSERT INTO employee (id, name) VALUES (1, 'Igor'); INSERT INTO employee (id, name) VALUES (2, 'Anton');
When i run
List<Employee> employeeList = unitOfWork.Employees.ToList()
LightSpeed makes following queries to database:
BEGIN OPEN :cur1 FOR
SELECT
EMPLOYEE.Id,
EMPLOYEE.Name
FROM
EMPLOYEE;
END;
--> Time: 81 ms
SELECT
KeyTable.NextId
FROM KeyTable
FOR UPDATE -->
Time: 8 ms
UPDATE KeyTable
SET NextId = 451
--> Time: 1 ms
And following employee list is assigned to employeeList variable:
Employee {Id = 451, Name = null }
Employee {Id = 2, Name = 'Igor'}
Employee {Id = 3, Name = 'Anton'}
Why first employee with Name = null has Id = 451 (not = 0) ?
Why LightSpeed updates KeyTable after selecting from EMPLOYEE table ?
PS: database: oracle 10g, Employee and UnitOfWork classes has been generated by designer
|
|
|
Hi, The 451 being inserted is a little curious. Generally speaking, LightSpeed prefers keys to not have a zero value - try starting by inserting with and ID of 1. Is this going to be an issue? It's something that has come up recently so we could look at reviewing it if it's a large issue for you. Could you see what value was in the KeyTable for the NextID prior to the select? My guess would be it's 450. Now, as for why the KeyTable is inspected right away when you're only doing a SELECT... LightSpeed will think that an entity with an Id of zero has no identity and thus select a block from the KeyTable. It will do this as soon as the Employee is loaded as it thinks it does not have an Id and therefore fetches a block from the KeyTable to give it one right away. I hope that helps, John-Daniel Trask |
|
|
It is issue fro me. I really need to have table rows with Id = 0. Each my table has row with Id = 0. It is special row. Using of such special rows allows me to reduce using of null values for foreign key columns, that allows to reduce using of LEFT JOIN, that simplify and accelerates queries. It is also simplifies:
public class LoadOptions public LoadOptions() public interface IQueryProvider Using example: List<Employee> employeeList = ( We could use other load options, such as SuppressLoadFromCache, UpdateCach. |
|
|
http://www.mindscape.co.nz/forums/Thread.aspx?ThreadID=2043
|
|
|
This is the same issue that I desribed in the link provided. Depending on your id type (keytable or identity) depends on what type of strange number your 0 entity will get when loaded. My guess is you are using keytable. Joe |
|
|
This is the exact way my tables are set up. A lot of legacy Access and web application use this null concept to allow you to select an item that have lookup tables. These tables never have new items added and if they do, they would not happen with LS. In my case,there are 20 known screens and web pages that depend on this 0 key. It would be nice to have a way to have a setting for the table to mark it as read only or something so the keys are not touched and self managed. Joe Feser |
|
|
Hi all, Just to update this thread, we have added initial support for identities of 0. This should appear in the next nightly build (dated the 17th of June). Please try it out and provide any feedback if you have any issues. I hope this helps, John-Daniel Trask |
|
|
I will check it out tomorrow night and provide feedback. |
|
|
Sorry it took so long to reply but it is not fixed if you want to save an entity that uses that relationship Lets say you have an order I get an error, "OrderStatus" is required and an exception is thrown. The work around is to make the foreign key relationship not required and then it works. Please email me of you need more information. Joe Feser |
|
|
I am using 6-23 build. |
|