Следующий отрывок является методом теста Junit 4 с зеленым светом:
@Test
public void testUnmarshallFromParentToChild() throws JAXBException {
Person person = new Person();
int age = 30;
String name = "Foo";
person.name = name;
person.age= age;
// Marshalling
JAXBContext context = JAXBContext.newInstance(person.getClass());
Marshaller marshaller = context.createMarshaller();
StringWriter writer = new StringWriter();
marshaller.marshal(person, writer);
String outString = writer.toString();
assertTrue(outString.contains("</person"));
// Unmarshalling
context = JAXBContext.newInstance(Person.class, RecieverPerson.class);
Unmarshaller unmarshaller = context.createUnmarshaller();
StringReader reader = new StringReader(outString);
RecieverPerson reciever = (RecieverPerson)unmarshaller.unmarshal(reader);
assertEquals(name, reciever.name);
assertEquals(age, reciever.age);
}
важная часть является использованием JAXBContext.newInstance(Class... classesToBeBound)
метод для контекста немаршалинга:
context = JAXBContext.newInstance(Person.class, RecieverPerson.class);
С этим вызовом, JAXB вычислит ссылочное закрытие на определенных классах и распознает RecieverPerson
. Тестовые передачи. И если Вы измените порядок параметров, то Вы доберетесь java.lang.ClassCastException
(таким образом, они будут должны быть переданными в этом порядке).
Being an old-fashioned sort of chap I still mainly get along with SQL*Plus and the TextPad IDE. TextPad is nagware, but the licence is cheap and the tool has some fantastic features. Also people have written PLSQL syntax libraries for it, which give you keyword highlighting. It is also possible to hook TextPad into other desktop tools such as Subversion.
SQL^Developer is written in java, which means it is a voracious consumer of memory. Still there is undoubted merit in having a data browser. Also the upcoming version 2.1 features built-in unit test, which could be very tasty.
Useful utilities:
In defence of Luddism
The danger with tools like TOAD and SQL*Developer is that they allow us to execute DML and DDL directly against the database, including editing PL/SQL source. This is fine and dandy and awfully in the spirit of Getting Things Done. Until we need to revert our changes. Or the production DBA demands a script....
Of course it is possible to use TOAD or SQL Developer in a safe fashion - I know SQL Developer can hook into source control as well - if just requires more self-discipline.
I always liked the PL/SQL Developer by Allround Automations - an excellent, quick and easy to use, and totally affordable tool!
For an interactive query shell - much better than SQL*Plus - I used to use "Golden" - a nice and powerful shareware tool, highly recommended.
Much better than anything else I ever tried with Oracle.
Marc
Might be a slightly different answer than you were expecting but I feel the Oracle documentation and in particular this book should be essential for any PL/SQL toolbox.
Мой основной редактор пакетов PL / SQL - SlickEdit. SlickEdit предлагает хорошую поддержку для разработки PL / SQL, хотя вы можете пропустить прямое подключение к базе данных, которое предлагают такие инструменты, как TOAD или SQLDeveloper. С другой стороны, работа с файлами PL / SQL (вместо непосредственной работы с объектами базы данных, как это делают многие пользователи TOAD) является хорошей практикой IMO для любого нетривиального проекта. В дополнение к SlickEdit я использую несколько самодельных вспомогательных программ, например, одну, которая загружает исходный код из базы данных и создает исходный файл, а другая - компилирует исходный код и вычисляет правильные номера строк для ошибок в файле, содержащем составные объекты, например, как спецификация пакета, так и тело.
Для прямого доступа к базе данных я предпочитаю SQLDeveloper, в основном потому, что он бесплатный и хорошо работает в Linux.
Я использую:
Редактор PLSQL Тоби может: